Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

4 Answers

up vote 2 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
add comment

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
add comment
: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
add comment

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

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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