[reordering as inline replies are preferred over top-posting on this
mailing list]
On 2015-01-20 13:33, Bao Niu wrote:
>> An example to replace "hello" with "goodbye":
>>
>> :%s/hello/goodbye/g
>>
>> Suppose you need to replace something with slashes in it.
>> The following attempt to replace "a/b" will NOT WORK:
>>
>> :%s/a/b/goodbye/g
>>
>> However, the following will work:
>>
>> :%s.a/b.goodbye.g
>
> Thank you John, but your advice makes me nervous. Does this dot
> ('.') rule also apply to vimgrep? Or it's only for substitution?
> This must be something that only pros use?
It's not something only for pros, and it works fine with vimgrep as
well as with the ":s" and ":g" commands:
:g@foo@p " print every line containing "foo", :g/foo/p
:vimgrep #\<for\># *.py
:%s!/foo/bar!/this/that!g
However, using a regexp meta-character such as "." does give me pause
I tend to fall back to one of "!", "@", or "#" depending on whether
any of them will appear in my regexp because none of them have
inherent meaning in a regexp, unlike the "." which means "any one
character".
-tim