在 VIM 中,是否可以在替换子句中使用选定的文本而无需重新键入? [英] In VIM, is it possible to use the selected text in the substitute clause without retyping it?

查看:34
本文介绍了在 VIM 中,是否可以在替换子句中使用选定的文本而无需重新键入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在视觉模式下选择了一个单词.我想使用 s//对该词和该词的所有其他实例在文件中执行替换.有没有办法在 s//stuff/ 部分使用突出显示的文本而无需重新输入?

Let's say I have a word selected in visual mode. I would like to perform a substitution on that word and all other instances of that word in a file by using s//. Is there a way to use the highlighted text in the s/<here>/stuff/ part without having to retype it?

推荐答案

好的.如果你选择了这个词,只需y"ank,然后输入:

Sure. If you selected the word, just "y"ank it, and then type:

:%s/<ctrl-r>"/something else/g

用 r 键按下 ctrl 键在哪里,而 " 只是 " 字符.

Where is pressing ctrl key with r key, and " is just " character.

所有按键:

y:%s/<ctrl-r>"/what to put/g<enter>

这篇关于在 VIM 中,是否可以在替换子句中使用选定的文本而无需重新键入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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