从搜索模式复制到 ex 模式

发布于 2024-08-14 14:58:41 字数 145 浏览 1 评论 0原文

在“/”模式下搜索时,如果需要复制到ex模式下怎么办?例如,我搜索了 /ab.*xy,现在我需要它作为 %s/ab.*xy/.../g

我的目的是测试我的搜索,然后将其用于搜索替换

While in the "/" mode to search, what should I do if need to copy it to the ex mode. E.g. I searched for /ab.*xy, now I need it as %s/ab.*xy/.../g.

My intention is to test my search and then use that for a search replace

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

双手揣兜 2024-08-21 14:58:41

使用/寄存器,在ex模式下按:

Ctrl-R/

Ctrl-R 允许插入寄存器的内容,/ 寄存器包含最后使用的搜索模式。

Use the / register, in ex mode press:

Ctrl-R/

Ctrl-R allows you to insert the contents of a register, and the / register contains the last search pattern used.

与君绝 2024-08-21 14:58:41

或者,您可以将搜索部分留空:

:/foo
:s//bar

如您所料,第一行找到“foo”。由于您在第二行中省略了搜索字符串,因此它只是重新使用相同的搜索,将“foo”替换为“bar”。我相信这在您键入搜索字符串的任何地方都有效 - 如果它为空,则意味着重新使用以前的搜索。

Alternatively, you can leave the search portion blank:

:/foo
:s//bar

The first line finds "foo", as you'd expect. Since you left off the search string in the second line, it just re-uses the same search, replacing "foo" with "bar". I believe this works anywhere you type a search string -- if it's blank, that means re-use the previous search.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文