Im using Markdown in Vim to write a lot of text. I'm wondering if its possible to make Vim automatically start the next line with a bullet * or - if I'm currently working on a text line in the list, and then presses enter ?
A lot of other text editors does this (e.g. Notational Velocity) so it would be great if this is possible in Vim as well.
What I want Vim to do:
- List element 1
- List element 2[press enter]
- (We are automatically here, with the bullet)
And I only want this for Markdown files.
Hope you understand! Thnx!
you need to set several vim variables to do it.
let's take '-' as example:
:set com=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,b:-
here the last 'b:-'
is important. it means, vim will think '-' and a space([tab] too) as comment leader, and will automatically added after you pressed Enter or o (normal mode). this set by :set formatoptions
. see following lines.
you could check
:h comments
:h format-comments
for details
:set formatoptions=tcroqln
here 'r' and 'o' are used for your requirement.
:h formatoptions
:h fo-table
for details
EDIT
for adding markdown filetype. many resources on the net. simply gave a shot on google, got one:
http://technicalpickles.com/posts/using-markdown-in-vim/
change au
to settings above, should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With