This snippet makes Vim automatically continue/end lists in insert mode, similar to the way word processors do:
- It automatically adds the bullet/number for the next list item when you press Return at the end of an existing item,
- When you press Return on an empty list item, it removes the bullet/number, ending the list.
It supports ordered lists with markers like 1.
and unordered lists with -
markers (because those are the markers I use.)
(It's particularly useful when using an iOS keyboard where punctuation and numerals are slow to access.)
If you're not sure how to install, just drop the markdown.vim
file itself in ~/vim/after/
, or if that file already exists, copy the code into it.
- I just use this for Markdown, but the code itself doesn't care about the
filetype
. It should be fairly easy to adjust it for different list styles. Making it a robust, multi-format extension would be a bit more work. - It supports lists with markers like
-
and1.
, because those are the list markers I use, but it would be easy to make it support more types of bullet/numbering. - I've just got it enabled for when I hit Return, but it'd be fairly easy to also enable it for normal mode o and O.
Let me know if you want to tweak it but don't know how to.
I've published my changes in a new gist.