开发者

Copy from search mode to ex mode

开发者 https://www.devze.com 2022-12-14 01:37 出处:网络
While in the \"/\" mode to search, what should开发者_Python百科 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.

While in the "/" mode to search, what should开发者_Python百科 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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消