我在文件中有很多行,我想将每行复制11次(将每行变成12行),并增加每行的最后一个“ 1”,以使12行从“ 1”到“ 12”,最初是“ 1”。每行中可能还会有其他出现的“ 1”,但是我要增加的“ 1”将始终是每行中的最后一个出现。另一种看待它的方法是最后一个“ 1”总是在“ / nt /”之后-像在“ / nt / 1”中一样(并且它始终是每行中唯一出现的“ / nt / 1”) 。
因此,例如,如果我有:
1stlineblahblahblah/nt/1blah
2ndlineblahblahblah/nt/1blah
3rdlineblahblahblah/nt/1blah
我想把它变成:
1stlineblahblahblah/nt/1blah
1stlineblahblahblah/nt/2blah
1stlineblahblahblah/nt/3blah
1stlineblahblahblah/nt/4blah
1stlineblahblahblah/nt/5blah
1stlineblahblahblah/nt/6blah
1stlineblahblahblah/nt/7blah
1stlineblahblahblah/nt/8blah
1stlineblahblahblah/nt/9blah
1stlineblahblahblah/nt/10blah
1stlineblahblahblah/nt/11blah
1stlineblahblahblah/nt/12blah
2ndlineblahblahblah/nt/1blah
2ndlineblahblahblah/nt/2blah
2ndlineblahblahblah/nt/3blah
...
我以前找到了命令:
:for i in range(0,12) | put ='1stlineblahblahblah/nt/'.i.'blah' | endfor
可以达到这个目的,但是我必须为每行手动运行此命令,然后自己输入(或复制并粘贴)每一行。有没有一种方法可以处理文件中已经存在的行,并仅运行一个命令就可以按照我描述的方式将每一行变成十二行?
在此先感谢任何可以帮助我的人。我也只想指出,这是我的第二个问题,我很高兴为第一个问题获得了几种快速有效的解决方案,对此我深表感谢。