我剛纔的問題似乎有點曖昧,我會改換: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