I often write text with a format like this in Vim—

- talking point 1

- talking point 2 ....
continue on point 2

Ideally, I would hope Vim could auto align it for me such as:

- talking point 1

- talking point 2 
  continue on point 2

Is this possible?


I've got this in my .vimrc:

set comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-,fb:[+],fb:[x],fb:[-]

If I remember correct, add this line in your .vimrc and the job will be done:

set comments +=fb:-

For a detailed explanation try:

:help comments
  • The second line did it for me. – Hugo Feb 14 '13 at 16:24
  • I'm downvoting this, because it seems like an abuse of vim's comment feature—bulleted lists are not comments. vim actually has a built-in feature for lists, so I strongly recommend @Kazark's answer instead. superuser.com/a/565514/219388 – Michael Scheper Jul 28 '20 at 19:46

If you have the n flag set in formatoptions (e.g. with set fo+=n), Vim already knows how to format lists with numeric bullets. formatlistpat (short name flp) is the regex Vim uses to match this, so what you need is to enhance that regular expression. This should do the trick for you (but only adds support for - bullets):

set formatlistpat=^\\s*\\(\\d\\+[\\]:.)}\\t\ ]\\|-\\)\\s*

Sorry for the backslash headache there. Doing set flp? shows more clearly what the regex looks like:

formatlistpat=^\s*\(\d\+[\]:.)}\t ]-\)\s*

For more information, see this post.

:set smartindent

if you need vim to break the line earlier than add

:set tw=30

or whatever number of chars per line you need.


See also: http://www.adp-gmbh.ch/vim/formatting/indenting_bullets.html

But also make sure that smartindent/cindent are not also set.

  • 1
    Welcome to Super User! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Peachy Nov 8 '12 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.