Vim Tips Wiki

Search without need to escape slash

Redirected from VimTip685

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 685 Printable Monobook Previous Next

created 2004 · complexity basic · author shaggy · version 5.7

This comes in handy if you have the full path of a file in your clipboard, and want to find it in your current buffer.

Instead of using "/" to search, use "?" then paste. You don't need to escape the frontslashes, so no need to edit the pattern.

If you wish to search forward, just hit "/" and Enter.

If you want to use it again, use the "?" history, not the "/".



This works on command line also, eg:

:g ?c:/tmp/x/y/z/? d

instead of

:g /c:\/tmp\/x\/y\/z\// d

Instead of '?' in line,

:g ?c:/tmp/x/y/z/? d

You can using any character as long as it is not in the search string, e.g.

:g -c:/tmp/x/y/z/- d

And you can use different characters for 'g' and 's' parts of a replacement search, eg:


Here is a neat way to use document searching:


change to the first instance of tmp found; leaves you in insert mode.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki