On 16/11/09 16:32, ALP wrote:
>
> Hi all,
>
> I'm new to the group so let me know if my question etiquette is
> lacking.
>
> I'm using gvim portable at work which utilizes vim 7.1.42 and in my
> vimrc I can't find the proper syntax for a search/replace regex with
> alternatives in a group; i.e.
>
> " delete all occurrences of foo and bar
> map ,blah :%s/\(foo\|bar\)//g
>
> from googling I've tried replacing "\|" with
> | \| \\|<Bar>  \<Bar>  \\<Bar>  <Bar>  and even<Leader><Bar>
>
>
> All either generate an error "Not an editor command" or compile but
> fail to have the desired behavior.
>
> Any thoughts, other permutations to try, or am I just making a silly
> mistake.
>
> Thanks a lot for any comments/thoughts.

I see you have a solution, but with the 'nocompatible' settings (and 
'cpoptions' at its "Vim default") I would have tried

        :map ,blah :%s/<Bslash>(foo<Bslash><Bar>bar<Bslash>)//g<CR>

i.e., replace
        \ by <Bslash>   everywhere in the {rhs}
        | by <Bar>      everywhere in the {rhs}
        and add <CR>    at the end, to execute the ex-command.

See ":help keycodes"

I might also have used a shorter {lhs}, for instance <F2> or <S-F8>

A different possibility would have been not to use a mapping at all, and 
to recall the :substitute from history. Depending on circumstances, one 
or the other may be better.


Best regards,
Tony.
-- 
hundred-and-one symptoms of being an internet addict:
196. Your computer costs more than your car.

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

Reply via email to