Vim Tips Wiki

Search without need to escape slash

1,612pages on
this wiki

Redirected from VimTip685

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.

Around Wikia's network

Random Wiki