tags:

views:

44

answers:

2

When I do a search and replace on a yanked line that has characters that require escaping it's really annoying to have to go back through the command line string and escape all the special characters.

Is there a way to use a literal (raw) string modifer like in python: str = r'\unescaped\'?

+2  A: 

Use the \V modifier:

:%s/\V$foo//g

See also :help /magic

innaM
It appears the literal backslash always needs to be escaped i.e. \\. Sigh.
Pierre-Antoine LaFayette
How could the backslash trick possibly work otherwise?
innaM
True, I thought of another solution... Using a different character than \ for the search and replace separaters, e.g. :%s;\foo\;bar;
Pierre-Antoine LaFayette
+1  A: 

I just thought of doing this instead: :%s;\foo\;bar;g. This solves the escape the backslash problem Manni points out.

Pierre-Antoine LaFayette