To search the string say /a/b/c/d/e/f/g/h/i in a file, is there a way to do
it without going to each / and escaping it to \/

:let @/ = escape('string with /slashes/, \backslashes\, .periods., *asterisks* etc.', '/\.*')

        n


Building on Tony's good suggestion...it's a good one, and an aircraft-carrier of a solution, swatting many more problems that are possible to arise, scaling to a full assault on the problem that consists of arbitrary escaping of any metacharacter.

However, if you want to *just* include forward-slashes, you can search *backwards* for them, and then reverse your direction:

        ?/a/b/c/d/e/f/g/h/i
        N

A slightly lazier way to do it with far less typing. :)

Or a hybrid approach:

        :let @/='/a/b/c/d/e/f/g/h/i'
        n

Once you've done either my first suggestion, you can use the regular "/" command and then use control+P to bring up the last search...magicomysteriously pre-escaped for you. :) This makes it handy to reverse the direction/meaning of n/N for future searches. I'm not sure why the second variant doesn't get remembered in the search history.

-tim


Reply via email to