gabrielelana / vim-markdown

Markdown for Vim: a complete environment to create Markdown files with a syntax highlight that doesn't suck!
MIT License
740 stars 59 forks source link

(Un)ordered list formatting could be cleverer #40

Closed aktau closed 8 years ago

aktau commented 8 years ago

I noticed than when formatting an (un)ordered list item that's too long, gabrielelana/vim-markdown would turn:

- qjweioqwje qwoiej wqoiejwq eioqwj eiowqje qwioejqw ioejqwio eqwe iqwje oqwiej qwoiejqw oiejqweioqw eoiqwjeqwioej qwioejqewije

Into

- qjweioqwje qwoiej wqoiejwq eioqwj eiowqje qwioejqw ioejqwio eqwe iqwje oqwiej
  - qwoiejqw oiejqweioqw eoiqwjeqwioej qwioejqewije

(which is doubly wrong, it shouldn't be indented nor a new list item).

But the default markdown syntax file that comes with Vim turns it into:

- qjweioqwje qwoiej wqoiejwq eioqwj eiowqje qwioejqw ioejqwio eqwe iqwje
  oqwiej qwoiejqw oiejqweioqw eoiqwjeqwioej qwioejqewije

Which is really nice. This has to do with the comments variable and possibly formatoptions as well.

gabrielelana/vim-markdown:

  formatoptions=tcrqon
  comments=b:*,b:-,b:+,n:>

vim:

  formatoptions=tcqln
  comments=fb:*,fb:-,fb:+,n:>

One of the main differences being that the comments variable in Vim has fb: instead of just b:. What's the reason for not specifying f here?

If this behaviour was intended, how do I best workaround this, in your opinion?

gabrielelana commented 8 years ago

One of the main differences being that the comments variable in Vim has fb: instead of just b:. What's the reason for not specifying f here?

That's because with f when you hit <Enter> you don't create the next list item but you stay in the same list item

With f (The | represents the cursor)

- List item<Enter>
  |

Without f

- List item<Enter>
- |

So yes, this is the intended behaviour, since I don't break long lines (:set textwidth=0), I prefer the <Enter> to create the next list item

Usually you would have <Enter> to create another list item, <Shift+Enter> to create another line in the same list item, unfortunately this is not possible in terminal vim

The workaround/fix could be override this behaviour with au FileType markdown setlocal com=fb:*,fb:-,fb:+,n:> fo=tcqln in your ~/.vimrc

Let me know if this works for you

aktau commented 8 years ago

Hi Gabriel!

One of the main differences being that the comments variable in Vim has fb: instead of just b:. What's the reason for not specifying f here?

That's because with f when you hit you don't create the next list item but you stay in the same > list item

Yes... I know.

So yes, this is the intended behaviour, since I don't break long lines (:set textwidth=0), I prefer the to create the next list item

Ah, that explains it.

It would work for me, but I found that I prefer the regular vim config in that case, it's cleaner.

Thanks!