M2bandit
M2bandit

Reputation: 99

How do you replace a line with forward slashes in it in EX?

I'm running a script for vim EX mode I've tried every escape character and word identifier I can find. it needs to find the string "/etc/walker" and replace it with "/etc/runner"

% s/\</etc/walker\>/\</etc/runner\>/g
wq

same issue with a script to append at the end of the file. It doesn't do anything. I'm trying to append "/etc/walker"

$
a
\</etc/walker\>
.
wq

what I've tried on regex editors seems to work there but not in EX

Thanks for your help

Upvotes: 0

Views: 25

Answers (1)

nbari
nbari

Reputation: 26925

Try this:

:s#/etc/walker#/etc/runner#

Notice the use of # as a delimiter, that way you don't have to add back slashes.

You could also use:

:s@/etc/walker@/etc/runner@

For appending at the end of the line:

:s#$#/etc/walker#

In EX mode just remove the : at the beginning.

Upvotes: 2

Related Questions