Thursday, March 3, 2011

Re: search and replace with word list

Hi,

jcordes wrote:
>
> Tim,
> I would like to have a better understanding of the line
>> :%s@.*@:-/MODULEX/s//&
>
> The two appearances of the @ symbol is puzzling me. Is this something
> to do with a search range for the substitute command, or executing a
> macro, or what?!

in the :substitute command you can use almost any non-alphanumeric
character for surrounding the search pattern and the replacement string.
Especially in this case this spares you the need for backslash-escaping
all the slashes in the replacement text. Otherwise you would need to
write

:%s/.*/:-\/MODULEX\/s\/\/&

You can read about this at

:help E146

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: