假设我有以下文本文件:
name: John Doe
description: My name is John Doe and I'm really good at vim!
name: John Doe
description: My name is John Doe and I'm really good at vim!
name: John Doe
description: My name is John Doe and I'm really good at vim!
name: John Doe
description: My name is John Doe and I'm really good at vim!
有没有一种方法可以记录一个宏,执行以下操作:
从第一个“John”开始:
cw
,但允许运行宏的用户在此处输入js<is>w
偷偷摸摸地获得“is”后面的单词。
用给定的输入替换John- 重复
@qJane
name: Jane Doe
description: My name is Jane Doe and I'm really good at vim!
@qJim
name: Jim Doe
description: My name is Jim Doe and I'm really good at vim!
getchar()
部分。 - Daniel Cookegetchar()
可能会有些棘手... 但如果你对此感兴趣,可以看一下 vim-surround 的前几行,里面有一些关于此的想法。vim-surround 插件执行类似于获取环绕字符和 HTML 标签的操作,这或许与你所需的接近。 - filbrandenfunction
后面的感叹号是用来干什么的? - Martín Nieva:help :function
。(一般来说,Vim拥有非常丰富的帮助系统,请首先使用它,因为在大多数情况下它可以直接回答您的问题。) - filbranden