4
4

4 回答 4

3

像往常一样查找您的文本/foo,然后使用c//e- 但请确保您使用//而不是仅使用/orn来查找后续匹配项。

//e表示重复上一次搜索,但光标放在单词的末尾,而不是开头。但是,e下次搜索时会记住标志,这就是为什么你需要在//之后使用。)

于 2010-01-31T16:51:59.857 回答
1

如果您想直观地批准您可以执行的每项更改

:%s/old/new/gc

编辑: 从其他答案听起来好像没有办法轻松获得选择。也许您可以使用 Vim 中的 python 脚本功能来编写命令来执行您想要的操作?

于 2010-01-31T16:11:15.247 回答
1

搜索字符串/不会选择它 - 它只会突出显示它。

要选择文本区域,请单击并在其上拖动鼠标或在正常模式下使用vVctrl-v键(分别通过线条或矩形区域选择正常区域),然后使用通常的移动键进行导航以扩展选择。这将使您进入视觉选择模式。

一旦您突出显示了一些文本并处于可视选择模式,您可以使用正常的编辑命令来更改突出显示的文本,例如c将删除文本并让您进入插入模式,y将拉动文本,gU将文本更改为大写,g?将 ROT13它等等

输入编辑命令后,您将返回正常模式,视觉高亮将消失。您可以使用 重新选择相同的区域gv

于 2010-01-31T16:51:36.727 回答
0

Try this:

:s//new_value

Why the downvote? You can map something like:

:nmap \s :s///<cr>``i

then search for your text, hit the mapping and you'll be in insert mode where your search text used to be. You can't use . but you can just use n\s for the next match.

There is no builtin text-object describing the text found by a search as far as I know.

于 2010-01-31T16:08:23.317 回答