开发者

vim string substitution

开发者 https://www.devze.com 2023-01-21 05:36 出处:网络
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:

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

开发者_C百科it doesn't work. Can anybody show me what is wrong?

Thanks,


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 


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消