有没有办法在vi(m)中生成数字序列?
例如,从文件中的随机行(在vim中打开),例如Row-i到随机行,例如Row-j,其中Row- Row-j,是否有一种方法来生成从Row-i到Row-j的数字序列,从数字1开始到数字j-i 1,步长递增为1?
说我在文件中有以下几行。
this is line #1 this is line #2 this is line #3 this is line #4 this is line #5 this is line #6 this is line #7 this is line #8 this is line #9 this is line #10
我想将数字序列从第4行到第8行开始从数字1到数字5的序列前缀。操作完成后,结果文件应如下所示:
this is line #1 this is line #2 this is line #3 1 this is line #4 2 this is line #5 3 this is line #6 4 this is line #7 5 this is line #8 this is line #9 this is line #10
如果这是可能的,有没有办法增加步数?例如,该序列应该是2,4,6,8,10,即具有步数2。
请注意:
这个SO post是相似的,但不一样。
用V(Shift-v)选择几行,然后输入命令:
原文链接:https://www.f2er.com/bash/389776.html:let i=1 | '<,'>g/^/ s//\=i . " "/ | let i+=2
类型:help sub-replace-expression来阅读更多。