Vim numbered lists
When writing markdown, it’s super common that you need numbered lists. (Neo)Vim has built-in support which makes creating numbered lists like a breeze.
Making a list of numbers article covers many approaches to creating lists, but it’s hard to find the true gem - automatic numbering.
See :help v_g_CTRL-A
{Visual}g CTRL-A
Add [count] to the number or alphabetic character in the
highlighted text. If several lines are highlighted, each one will be
incremented by an additional [count] (so effectively creating a [count]
incrementing sequence).
So, let’s say you have following text:
No uppercase, No underscore
3-63 characters long
Not an IP
Must start with lowercase letter or number
Must NOT start with the prefix `xn--`
Must NOT end with the suffix `-s3alias`
And you want to turn it into a numbered list. You can do by:
- Select a visual block of the first symbols in the line, see
:help v_CTRL-V
- Press
SHIFT-I
for a visual block insert, see:help v_b_I
- Type
1.
and exit insert mode - Reselect the selection by
gv
, see:gv
- Exclude first line by pressing
o
, followed byj
- Automatically increment the numbers by typing
g
followed byCTRL-A
.
Comments