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

Long list items don't indent on wrap.

Open andrew-vant opened this issue 8 years ago • 7 comments

If I have a markdown list with items longer than two lines, lines past the second don't autowrap correctly. e.g.:

1. Lorem ipsum dolor sit amet
2. consectetur adipiscing elit, sed do eiusmod
3. tempor incididunt ut labore et dolore magna aliqua. Ut enim  # OK
   ad minim veniam, quis nostrud exercitation ullamco laboris   # OK
nisi ut aliquip ex ea commodo consequat. Duis aute irure        # Wrong, not indented
dolor in reprehenderit in.                                      # Still wrong
4.  voluptate velit esse cillum dolore.
5. ...and so on

I'm not entirely sure this is a bug rather than interference from something else in my vim config, but I couldn't find anything obvious to cause it.

andrew-vant avatar Apr 04 '16 21:04 andrew-vant

I've been experiencing this for quite a while, but always just Vjjjj>> and manually shove the lines over afterward. My .vimrc is pretty straightforward, so I'm pretty sure this behavior is from vim-markdown.

jakewisse avatar Jan 30 '17 14:01 jakewisse

Any possible fix in the near future? This is quite frustrating, since I come across a lot of these, these days.

jerinphilip avatar Oct 07 '17 06:10 jerinphilip

I am also experiencing this.

jgrar avatar Mar 19 '18 12:03 jgrar

It's just 'formatoptions'. The problem is that fixing one behavior tends to break another.

tpope avatar Mar 19 '18 16:03 tpope

@tpope You are correct. I fixed it with se fo-=2 ai just now.

jgrar avatar Mar 21 '18 06:03 jgrar

The indentexpr function used in indent/rst.vim in upstream Vim seems to address this issue.

Skipping the " Indent :FIELD: lines. portion of GetRSTIndent that is unnecessary for Markdown, that function looks like it should work as-is for Markdown as well (except for the current footnote reference support).

dandersson avatar Jul 16 '18 16:07 dandersson

This issue can be fixed with set autoindent in a vimrc file.

Note that the list continuation behavior is provided by the n option of formatoptions. If you check the formatoptions documentation with :h fo-table, you'll see next to n: "Note that 'autoindent' must be set too." My guess is that the n option only does anything special when going from the first item of a list option to the second, and then relies on autoindent to keep the indentation level consistent past that.

It might be reasonable for this plugin to set autoindent.

msuperdock avatar Jan 25 '19 21:01 msuperdock