Macro for making numbered lists in vim?

后端 未结 7 1943
渐次进展
渐次进展 2021-02-12 03:40

Often times it seems I have a list of items, and I need to add numbers in front of them. For example:

Item one
Item two
Item three

Which shoul

7条回答
  •  执念已碎
    2021-02-12 04:31

    Select your lines in visual mode with: V, then type:

    :'<,'>s/^\s*\zs/\=(line('.') - line("'<")+1).'. '
    

    Which is easy to put in a command:

    command! -nargs=0 -range=% Number ,s/^\s*\zs/\=(line('.') - +1).'. '
    

提交回复
热议问题