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

Re: accelerate seven (or more) substitute

Expand Messages
  • Christian Brabandt
    Hi epanda! ... let subst[ foo ] = bar let subst[ oof ] = rab let subst[ fof ] = arb let subst[ ofo ] = abr exe :%s/ . join(keys(subst), | ).
    Message 1 of 6 , Dec 30, 2009
    • 0 Attachment
      Hi epanda!

      On Mi, 30 Dez 2009, epanda wrote:

      > foo to change to bar
      > oof to change to rab
      > ofo to change to abr
      > fof to change to arb
      > etc...
      >
      > all word are different

      let subst['foo'] = 'bar'
      let subst['oof'] = 'rab'
      let subst['fof'] = 'arb'
      let subst['ofo'] = 'abr'
      exe ':%s/' . join(keys(subst), '\|'). '/\=subst[submatch(0)]/g'


      regards,
      Christian
      --
      hundred-and-one symptoms of being an internet addict:
      38. You wake up at 3 a.m. to go to the bathroom and stop and check your e-mail
      on the way back to bed.

      --
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • epanda
      ... I have to declare subst like that I think : let subst = {} I think this command is very powerful, I didn t know this combination of (join and other stuff).
      Message 2 of 6 , Dec 30, 2009
      • 0 Attachment
        On 30 déc, 13:41, Christian Brabandt <cbli...@...> wrote:
        > Hi epanda!
        >
        > On Mi, 30 Dez 2009, epanda wrote:
        >
        > > foo to change to bar
        > > oof to change to rab
        > > ofo to change to abr
        > > fof to change to arb
        > > etc...
        >
        > > all word are different
        >
        > let subst['foo'] = 'bar'
        > let subst['oof'] = 'rab'
        > let subst['fof'] = 'arb'
        > let subst['ofo'] = 'abr'
        > exe ':%s/' . join(keys(subst), '\|'). '/\=subst[submatch(0)]/g'
        >
        > regards,
        > Christian
        > --
        > hundred-and-one symptoms of being an internet addict:
        > 38. You wake up at 3 a.m. to go to the bathroom and stop and check your e-mail
        >     on the way back to bed.

        I have to declare subst like that I think : let subst = {}

        I think this command is very powerful, I didn't know this combination
        of (join and other stuff).

        You script says to me that the key OOF does not exist in the
        Dictionnary. E476.



        --
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
      • epanda
        ... It is ok, just the I flag to put at the end like this exe :%s/ . join(keys(subst), | ). / =subst[submatch(0)]/Ig in order toavoid case problem --
        Message 3 of 6 , Dec 30, 2009
        • 0 Attachment
          On 30 déc, 13:41, Christian Brabandt <cbli...@...> wrote:
          > Hi epanda!
          >
          > On Mi, 30 Dez 2009, epanda wrote:
          >
          > > foo to change to bar
          > > oof to change to rab
          > > ofo to change to abr
          > > fof to change to arb
          > > etc...
          >
          > > all word are different
          >
          > let subst['foo'] = 'bar'
          > let subst['oof'] = 'rab'
          > let subst['fof'] = 'arb'
          > let subst['ofo'] = 'abr'
          > exe ':%s/' . join(keys(subst), '\|'). '/\=subst[submatch(0)]/g'
          >
          > regards,
          > Christian
          > --
          > hundred-and-one symptoms of being an internet addict:
          > 38. You wake up at 3 a.m. to go to the bathroom and stop and check your e-mail
          >     on the way back to bed.


          It is ok, just the I flag to put at the end like this exe ':%s/' .
          join(keys(subst), '\|'). '/\=subst[submatch(0)]/Ig' in order toavoid
          case problem

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