I am writing a bulletted list in VIM, and have set textwidth=79 to hard wrap the lines. As I write the list, I would like for each carriage return to produce a new bullet and for the wrapped lines to not have bullets. However, VIM is doing the opposite (bullets on wrapped lines, no bullets after carriage return). I would like:
* Item 1 - The text for this line is too long and
so is wrapped to the next line.
* Item 2 - Typing a carriage return after item 1
should produce the bullet for this item.
However, VIM does this:
* Item 1 - The text for this line is too long and
* so is wrapped to the next line.
Item 2 - Typing a carriage return after item 1
should produce the bullet for this line.
I have autoindent on, cindent off, and formatexpr is an empty string. I understand and like the auto-inserted '*' behavior for C-style comments, but would like different behavior for text filetypes. Is there a setting that allows this?
Try
set formatoptions=tn autoindent
let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|[*-]\s\)\s*'
The n flag in formatoptions triggers the formatting of lists that you are after but the default setting of formatlistpat only handles numbered lists. The one above adds bullets of either *
or -
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With