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

reusing result of wildcard in substitution of pattern

Expand Messages
  • Robert Cussons
    Hi all, I have a pattern for example: {Q ^{(a)}} but the a can also be another letter, I know how to search for these items: {Q ^{(.)}} however if I now want
    Message 1 of 3 , Apr 2, 2008
    • 0 Attachment
      Hi all,

      I have a pattern for example:
      {Q\^{(a)}}

      but the 'a' can also be another letter, I know how to search for these
      items:
      {Q\^{(.)}}

      however if I now want to substitute for this pattern but preserve the
      letter, I would think of using something like this:
      :1570,1762s/{Q\^{(.)}}/{Q\^{()}; K}/gc

      except, how do I get the character matched by the '.' in the search
      string to appear in the replacement string, i.e. between the second set
      of ()?

      Many thanks,
      Rob.


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Charles E Campbell Jr
      ... Regards, Chip Campbell --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist. For more information,
      Message 2 of 3 , Apr 2, 2008
      • 0 Attachment
        Robert Cussons wrote:
        > Hi all,
        >
        > I have a pattern for example:
        > {Q\^{(a)}}
        >
        > but the 'a' can also be another letter, I know how to search for these
        > items:
        > {Q\^{(.)}}
        >
        > however if I now want to substitute for this pattern but preserve the
        > letter, I would think of using something like this:
        > :1570,1762s/{Q\^{(.)}}/{Q\^{()}; K}/gc
        >
        > except, how do I get the character matched by the '.' in the search
        > string to appear in the replacement string, i.e. between the second set
        > of ()?
        >
        :help /\(
        :help /\1

        Regards,
        Chip Campbell


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Robert Cussons
        ... Thanks very much Chip, that s exactly what I was looking for. Rob. --~--~---------~--~----~------------~-------~--~----~ You received this message from the
        Message 3 of 3 , Apr 3, 2008
        • 0 Attachment
          Charles E Campbell Jr wrote:
          > Robert Cussons wrote:
          >> Hi all,
          >>
          >> I have a pattern for example:
          >> {Q\^{(a)}}
          >>
          >> but the 'a' can also be another letter, I know how to search for these
          >> items:
          >> {Q\^{(.)}}
          >>
          >> however if I now want to substitute for this pattern but preserve the
          >> letter, I would think of using something like this:
          >> :1570,1762s/{Q\^{(.)}}/{Q\^{()}; K}/gc
          >>
          >> except, how do I get the character matched by the '.' in the search
          >> string to appear in the replacement string, i.e. between the second set
          >> of ()?
          >>
          > :help /\(
          > :help /\1
          >
          > Regards,
          > Chip Campbell

          Thanks very much Chip, that's exactly what I was looking for.

          Rob.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        Your message has been successfully submitted and would be delivered to recipients shortly.