Wikia

Vim Tips Wiki

Search without need to escape slash

Talk0
1,612pages on
this wiki
Revision as of 02:11, May 16, 2012 by JohnBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 "/".

ReferencesEdit

CommentsEdit

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:

:g#/tmp/#s//#tmp#/

Here is a neat way to use document searching:

c/tmp

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


Around Wikia's network

Random Wiki