Macro for making numbered lists in vim?

后端 未结 7 2270
盖世英雄少女心
盖世英雄少女心 2021-02-12 03:50

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:26

    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).'. '
    

提交回复
热议问题