VIM:如何选择和替换一个单词以使其所有外观



在文件中,我希望用"媒体"替换所有"中间",我不想使用

:%s:中间:中:g

我想

1. put the focus on the word of "middle"
2. press 'gd' to high light it, 
3. and then do something to replace all its appearance(multiple places) into "medium". 

更重要的是,当我替换一个单词时,在打字时,所有位置都会显示相同的更改?

如何执行此操作,我应该使用正常模式或视觉模式吗?

第一个问题

您可以使用:help gn

*                 jump to the next occurence of the word under the cursor
``                jump back
cgnmedium<Esc>    change it to whatever you want
.                 repeat change on next occurrence
.                 repeat change on next occurrence
.                 repeat change on next occurrence

如果需要的话,可以映射:

nnoremap <key> *``cgn

第二个问题

否,但是如果您真的想要这样的功能,则可以使用Google进行"多光标VIM"。

最新更新