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

RE: Buffer actions

Expand Messages
  • Persson Jonas
    Yes, that did work! Thanks. / Jonas ... From: Tim Chase [mailto:vim@thechases.com] Sent: den 5 maj 2005 00:00 To: Persson Jonas Cc: vim@vim.org Subject: Re:
    Message 1 of 7 , May 4, 2005
    • 0 Attachment
      Yes, that did work! Thanks.

      / Jonas

      -----Original Message-----
      From: Tim Chase [mailto:vim@...]
      Sent: den 5 maj 2005 00:00
      To: Persson Jonas
      Cc: vim@...
      Subject: Re: Buffer actions

      >> :bufdo let found=0 | exe "0;/regexp/g/regexp/let found=1" |
      >> if (!found) | $put ='hello' | endif
      >
      > Unfortunatly this did not work. If the pattern is not found,
      > the command is aborted with "E486: Pattern not found" before
      > the if() is executed.

      Sorry...some of that was a bit untested, trying to add your handy
      "cut" technique (in Prolog terminology) to only set it once. Try


      :bufdo let found=0 | exe "g/regexp/let found=1" | if (!found) |
      $put ='hello' | endif

      which can set "found" more than once...inefficient, but not
      killer. This was the actual expression I tested, but wanted to
      try your technique of using the "0;/regexp/" which looked
      promising. However, I forgot about the error-condition
      triggering a stop.

      Any better?

      -tim
    Your message has been successfully submitted and would be delivered to recipients shortly.