5

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?

Kazark
  • 3,509
Oliver
  • 275
  • 1
  • 3
  • 6

4 Answers4

6

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.

Kazark
  • 3,509
5

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
vbd
  • 485
0
: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.

akira
  • 63,447
0

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

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

macetw
  • 170