I have a plugin that can (Partially?) helps you: lazyList (No automatic list numbering).
In the following example (_
is the cursor position) ...
1. Some text
2. More text
Sub-secti_on text
Sub-section text
Sub-section text
... simply execute the command :LazyList '2.%1%. '
to get:
1. Some text
2. More text
2.1. Sub-secti_on text
2.2. Sub-section text
2.3. Sub-section text
To remove the indices, execute the same command.
By default, the indices are added to the current paragraph (Same indentation or when surrounded by empty lines), but you can add them to a visual selection.
A good way of doing in your case:
- Add indices
- Remove the indices before adding a new element(s).
- Add indices after adding the new element(s).
This video should be more explicit.
The bad thing with the plugin, is that it doesn't take in account a visual selection with empty lines, I should reconsider this behavior.
P.S English is not my native language, so please excuse the mistakes.
asciidoc
can later be used to convert the markdown into a PDF with line numbering. But I too would like to know how to use vim for automated line numbering of text-only files.-
, second level list items with--
, etc. This seems the most likely avenue of approach; see my recent question about consecutive numbering in Ex-mode for a starting point.