我刚才的问题似乎有点暧昧,我会改换:Vim的复制和粘贴
我有一个这样的文件:
copythis abc
replacethis1 xyz
qwerty replacethis2
hasfshd replacethis3 fslfs
And so on...
注: replacethis1,replacethis2,replacethis3, ...可以是任何文字
如何用“最少vim命令”替换“replacethis1”,“replacethis2”,“replacethis3”,..“copythis”字。我可以做
一种方式是通过下列步骤操作:
- 删除 “replacethis1”, “replacethis2”, “replacethis3”,...利用 'DW'
- 复制 “copythis” 使用“YW '
- 将光标移动到“replacethis1”所在的位置并做'p';将光标移动到“replacethis2”所在的位置,并执行“p”等等...
有没有更好的方式在VIM中执行此操作(使用较少数量的vim命令)?
,具体取决于您如何移至不同的待替换单词,最好使用ciw(或caw)而不是cw。为了顺利工作,你需要在更换这个开始。 – user55400 2009-03-02 13:33:21