Friday, June 21, 2013

Re: Subvert substitution to comma

On Fri, June 21, 2013 09:45, Claus Atzenbeck wrote:
> Hi all:
>
> When using :Subvert
> <http://www.vim.org/scripts/script.php?script_id=1545>, how can I
> substitute with comma and curly braces?
>
> For example, I'd like to substitute the following with one shot:
>
> "Ñ" &#8594;í ",,"
> "Ö" &#8594;í "\dots{}"
>
> However, Subvert does not work:
>
> :%Subvert /{Ñ,Ö}/{,,,\dots{}}
> ^^ ^^
>
> The issue is that :Subvert requires a comma separated list. Furthermore,
> the curly braces have a different meaning. Escaping those characters
> with backslash does not work; wrapping them into quotation marks does
> not work either.
>
> Is this possible at all with Subvert?

You don't need a plugin for that. It is simple by defining a
dictionary and use that in the :s command.

let dict = {'Ñ': ',,', 'Ö': '\dots{}'}

:exe "%s/".join(keys(dict), '\|').'/\=dict[submatch(0)]/eg'


regards,
Christian

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment