On 11/06/09 11:35, Vincent Arnoux wrote:
>
> Hi List,
> I know how to insert the same text on multiple consecutive lines
> (visual mode ->  select a column ->  Type "I" and type the text). Is
> there a way to select multiple places (not close one to each other) in
> a document and insert text at those places at once?
>
> Vincent

Depends what exactly you want to do. Here are a few examples:

        " replace everywhere "this" (only if used as a word)
        " by "this and that"
        :%s/\<this\>/this and that/g

        " add /* before and */ after every line containing "stuff"
        :%g/\<stuff\>/s/^.*$/\/\* \0 \*\//
or
        :%s/^.*\<stuff\>.*$/\/\* \0 \*\//

        " delete "bar" (if present as a word) in any line
        " containing "foo" (as a word)
        :%g/\<foo\>/s/\<bar\>//ge

see
        :help :s
        :help :g

and what these link to.

There is no way to have _multiple_ visual selections at any single time, 
but if you can tell Vim how to find (by a regexp) the multiple places 
where you want to insert text, then it can do it.


Best regards,
Tony.
-- 
"I thought you were trying to get into shape."
"I am. The shape I've selected is a triangle."

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to