Home » Questions » Computers [ Ask a new question ]

bulleted lists for plain-text documents in Vim

bulleted lists for plain-text documents in Vim

While Vim supports automatic indenting in lists, the default setting only covers ordered lists, starting with digits, such as:

Asked by: Guest | Views: 241
Total answers/comments: 2
Guest [Entry]

"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*"
Guest [Entry]

"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\\+"