如何在vim中插入类似的行时最小化击键?
发布时间:2020-12-16 01:08:10 所属栏目:安全 来源:网络整理
导读:有时我需要在文件中插入一些类似的行,这些行仅在序列号上有所不同.例如, print "func 1";print "func 2";print "func 3";print "func 4";print "func 5"; 使用vim,我最后使用[yypppp]复制粘贴第一行,然后更改最后四行.如果要插入更多行,这非常慢. 在vim中有
有时我需要在文件中插入一些类似的行,这些行仅在序列号上有所不同.例如,
print "func 1"; print "func 2"; print "func 3"; print "func 4"; print "func 5"; 使用vim,我最后使用[yypppp]复制粘贴第一行,然后更改最后四行.如果要插入更多行,这非常慢. 在vim中有更快的方法吗? 一个例子是:
boot(); format(); parse(); compare(); results(); clean();
print "func 1"; format(); print "func 2"; parse(); print "func 3"; compare(); print "func 4"; results(); print "func 5"; clean();
录制一个宏.以下是您的特定示例的工作流程:
复制粘贴第一行.然后, qa : Start recording macro to register a yy : Yank current line p : Paste current line in line below /d : Search for start of number (you can skip this command,the next command automagically moves the cursor to the number) C-A : Control-A increments the number q : Stop recording macro 3@a : Replay macro 3 times 您可以使用任意数字替换3以继续生成具有递增数字的新打印行. 对于您的第二个示例,您可以添加 j : Moves one line down 在yy命令之后,获得交替的命令和打印行. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读