在 Vim 中,替换光标下所有出现的当前术语 [英] In Vim, replace all occurrences of current term under cursor

查看:25
本文介绍了在 Vim 中,替换光标下所有出现的当前术语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在 Vim 中按 *,编辑器将在同一文件中搜索该术语的下一次出现.它使您不必输入术语.

If you press * in Vim, the editor will search for the next occurrence of the term in the same file. It saves you from having to type out the term.

有没有一种快速的方法可以用新的术语替换当前光标下的术语?一个字符来发出命令,输入新术语,然后 Enter.

Is there a quick way to replace the term currently under the cursor with a new one? One character to issue the command, typing in the new term, then Enter.

推荐答案

您可以使用:

:%s/<c-r><c-w>/new value/g

其中 表示按字面输入 CTRL-rCTRL-w 插入光标下的单词.

where <c-r><c-w> means to literally type CTRL-rCTRL-w to insert the word under the cursor.

这篇关于在 Vim 中,替换光标下所有出现的当前术语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆