0

When writing indented fenced codeblocks (the only ones I use) like

    ```sh
    some shell code
    ```

in markdown the indentation of comments is automatically removed when I type the comment character #.

    ```sh
# as soon as I type '#' the indentation is removed
    ```

Also, the indentation in normal mode using > does not work on the comments (even though the rest is properly indented).

Note, I do not use any markdown specific plugins, but make use of the default syntax highlighting using

  let g:markdown_fenced_languages = [
    \ 'py=python', 'python',
    \ 'sh', 'bash=sh', 'shell=sh',
    \ 'c', 'c++=cpp',
    \ 'rb=ruby', 'ruby',
    \ 'html', 'css',
    \ 'js=javascript', 'javascript',
    \ 'json',
    \ 'yaml', 'yml=yaml',
    \ 'vim'
  \]

How do I debug this to find the cause?

Stefan
  • 179
  • 7

1 Answers1

2

Remove set smartindent from your configuration.

Excerpt from the :h 'smartindent'

        When typing '#' as the first character in a new line, the indent for
        that line is removed, the '#' is put in the first column.  The indent
        is restored for the next line.  If you don't want this, use this
        mapping: ":inoremap # X^H#", where ^H is entered with CTRL-V CTRL-H.
        When using the ">>" command, lines starting with '#' are not shifted
        right.

How do I debug this to find the cause?

As usual, start with no config, check if it works, and add half of the config, check, etc. How do I debug my vimrc file? should also apply to neovim wrt to adjusted vimrc -> init.vim/lua and runtimepath changes maybe.

Maxim Kim
  • 13,376
  • 2
  • 18
  • 46