bulleted lists for plain-text documents in Vim

Solution 1:

Knowing what you tried to set the value to would help, but I'm guessing you didn't properly escape the backslashes.

The default value is

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

but to actually set that value (in your vimrc or at the cmdline) you have to use

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

This is explained in :help option-backslash. A simple modification to allow formatlistpat to work with * delimited, unordered lists would be

set formatlistpat=^\\s*[0-9*]\\+[\\]:.)}\\t\ ]\\s*

Solution 2:

In addition to what jamessan wrote (in particular his formatlistpat suggestion for working with * lists), it is important to have the 'c' option (comment formatting) unset in formatoptions:

set formatoptions-=c

otherwise Vim gets confused between the formatting of * bulleted lists and the formatting of comments. You end up with an extra * on the 2nd and following lines.

Solution 3:

I had some trouble getting lists like a) recognized, so I'll post my solution here:

" Recognise lists like 1), 1., a), a., and so on
" Note that | need to be escaped AND preceeded by a literal backslash
set formatlistpat=^\\s*\\([0-9]\\+\\\|[a-z]\\)[\\].:)}]\\s\\+

Solution 4:

I am writing a new answer to this question because I had to combine multiple answers from this question and this other question to make this work. Here is my final configuration.

set formatlistpat=^\\s*[0-9*]\\+[\\]:.)}\\t\ ]\\s*
set formatoptions-=c
set comments-=mb:*