Loading ...
Sorry, an error occurred while loading the content.

Subvert substitution to comma

Expand Messages
  • Claus Atzenbeck
    Hi all: When using :Subvert , how can I substitute with comma and curly braces? For example, I d like to
    Message 1 of 2 , Jun 21, 2013
    • 0 Attachment
      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:

      "„" → ",,"
      "…" → "\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?

      Best,
      Claus

      --
      --
      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@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Christian Brabandt
      ... 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{} } ...
      Message 2 of 2 , Jun 21, 2013
      • 0 Attachment
        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:
        >
        > "Ñ" →í ",,"
        > "Ö" →í "\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@....
        For more options, visit https://groups.google.com/groups/opt_out.
      Your message has been successfully submitted and would be delivered to recipients shortly.