less than 1 minute read

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:

  1. Select a visual block of the first symbols in the line, see :help v_CTRL-V
  2. Press SHIFT-I for a visual block insert, see :help v_b_I
  3. Type 1. and exit insert mode
  4. Reselect the selection by gv, see :gv
  5. Exclude first line by pressing o, followed by j
  6. Automatically increment the numbers by typing g followed by CTRL-A.

Tags:

Categories:

Updated:

Comments