Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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
share|improve this answer
The second line did it for me. – Hugo Feb 14 '13 at 16:24

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.

share|improve this answer
: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.

share|improve this answer

See also:

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

share|improve this answer
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .