vim-markdown icon indicating copy to clipboard operation
vim-markdown copied to clipboard

fenced code block indentation indent autoindent

Open bryansammon opened this issue 6 years ago • 2 comments

I have this code in a markdown file, syntax.md (from the tests) but when I attempt to autoindent it (gg=G) it seems to remove the indenting from the ruby code block. Is auto indentation possible in a fenced code block?

Im on vim 8.1 (including patches 1-606)

def f
  0
end

After I use the gg=G command it shows like this:

def f
0
end

set indentexpr? returns indentexpr=GetMarkdownIndent()

I would like to keep it indented. Also, all of the tests seem to pass fine, which leads me to believe it may not be capable. If this isnt a possibility what do you do for auto indented fenced code blocks in markdown?

bryansammon avatar Jun 18 '19 01:06 bryansammon

Same problem here on neovim. Is there any solution yet?

bouncepaw avatar Nov 30 '19 11:11 bouncepaw

Add the following code to /path/to/plugin/indent/markdown.vim around line 60 in GetMarkdownIndent() function. It should do the trick (not messing with the indentation of the fenced code)

    let hg = join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'))
    if hg =~ 'mkdSnippet*'
        return -1
    endif

YasserKa avatar Jan 12 '21 23:01 YasserKa