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

Re: search and replace with word list

Expand Messages
  • jcordes
    ... Indeed it does help, Tim -- greatly! Thank you very much, for this and your many other helpful posts. John -- You received this message from the vim_use
    Message 1 of 11 , Mar 4, 2011
    • 0 Attachment
      On Mar 4, 8:19 am, Tim Chase <v...@...> wrote:
      > On 03/04/2011 05:55 AM, jcordes wrote:
      >
      > >>>   I would like to have a better understanding of the line
      > >>>>     :%s@.*@:-/MODULEX/s//&
      >
      > > I saw only *two* occurrences of the "@" character -- where is
      > > the third @? I think I am confused by the fact that this is
      > > not a straightforward 'substitute' command -- at least so it
      > > appears to me.
      >
      > Only the first delimiter is required.  The 2nd two are implicit
      > if omitted.  I'd drop you right to it in the help if there was an
      > exact-tag for it, but if you go to
      >
      >    :help E146
      >
      > and skim backwards for "omited", you'll hit the somewhat oblique text
      >
      > """
      > If the {string} is omitted the substitute is done as if it's
      > empty.  Thus the matched pattern is deleted.  The separator after
      > {pattern} can also be left out then.  Example:
      >         :%s/TESTING
      > This deletes "TESTING" from all lines, but only one per line.
      > """
      >
      > where "{string}" refers WAAAAAAY back to the "{string}" at the
      > top of ":help :s"
      >
      > So the following are all the same:
      >
      >    :%s/foo//
      >    :%s/foo/
      >    :%s/foo
      >
      > and if "foo" is already in the search buffer as if you did
      >
      >    /foo
      >
      > (or hit "*" or "#" on the Word "foo"...if you're playing VimGolf
      > -- at least one of the challenges makes use of this) then you can
      > even do any of the following which are the same
      >
      >    :%s/
      >    :%s//
      >    :%s///
      >
      > to get the same result.  Then add to that mix the ability to use
      > non-alphanumeric chars as the delimiter and you arrive at my
      >
      >    s@pattern@replacement_with_lots_of_slashes
      >
      > as I only want the first one, so I can omit the "@flags"
      >
      > Hope that helps (and didn't slam you with too much information as
      > I'm apt to do ;-)
      >
      > -tim

      Indeed it does help, Tim -- greatly!
      Thank you very much, for this and your many other helpful posts.

      John

      --
      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
    Your message has been successfully submitted and would be delivered to recipients shortly.