Questions tagged «enumerate»

8
如何在文件中添加永久行号?
我有一个这样的文本文件(在Windows上使用gVim) foo bar baz quux corge grault garply waldo fred plugh [...150 more lines...] xyzzy thud 我想在文件的每一行中添加一个数字。不使用:set number,而是将数字添加为每行之前的文本,如下所示,因此该数字是文件的一部分。 1. foo bar baz quux 2. corge grault garply 3. waldo fred plugh [...~150 more lines...] 155. xyzzy thud

5
如何复制每行11次,将每行的最后一个“ 1”从2-12递增
我在文件中有很多行,我想将每行复制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' | …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.