tags:

views:

59

answers:

3

Hi,

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,

A: 

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

Raghuram
He explicitly states that he's done that in the question.
Nathan Tomkins
Ok i missed it ....
Raghuram
+1  A: 

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
codaddict
+1  A: 

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 
Jayan
this is cool. Is the # symbol only understood by vim or vi also?
Sean Nguyen
Whatever character that follows the substitute command is understood as the delimiter by vi, vim, sed, etc.
Luc Hermitte