Sean Nguyen
Sean Nguyen

Reputation: 13118

vim string substitution

I want to substitute all cygdrive/e with cygdrive/d using vim. But I can't get the matching pattern correctly. Here is my command:

s/cygdrive\/e/cygdrive\/d/g

it doesn't work. Can anybody show me what is wrong?

Thanks,

Upvotes: 2

Views: 347

Answers (3)

Jayan
Jayan

Reputation: 18459

vim allows you to specify the delimiter.. (First character after s is the delimiter)

s/cygdrive\/e/cygdrive\/d/g 

using line range argument .. and # as delimiter

ESC:
:1,$    s#/cygdrive/e#/cygdrive/d#g 

Upvotes: 3

codaddict
codaddict

Reputation: 454950

Your search pattern and replacement string look fine.

Make sure you are in ex mode when you try it.

So press ESC, then : and then

%s/cygdrive\/e/cygdrive\/d/g

But if you want all he replacements in just the current line you can do:

s/cygdrive\/e/cygdrive\/d/g

Upvotes: 2

Raghuram
Raghuram

Reputation: 3967

You have to escape the special character like this s/cygdrive\/e/cygdrive\/d/g

Upvotes: -2

Related Questions