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

87886Re: Explanation on \zs

Expand Messages
  • ACR
    Feb 29, 2008
    • 0 Attachment
      Thanks a lot Tony..
      I am trying out this in the :substitute command. For eg.
      I can use
      :%s/\(foo.*\)\@<=./-/g
      To replace
      "Hello, this string is foo. Please check" to "Hello, this string is
      ---------------------------------"
      But, am not able to explain the behaviour. How does this command
      work?

      Also, would like to know who \zs can replace \@<= in this command and
      the result be the same.

      Thanks,
      Anith.

      On Feb 29, 11:26 am, Tony Mechelynck <antoine.mechely...@...>
      wrote:
      > ACR wrote:
      > > Hi all,
      >
      > > Can someone suggest a good method to learn the \zs, \ze, \@<=
      > > options? I am trying to make sub-line modifications in my text
      > > files. I am not quite following the :help \zs explanations. A more
      > > detailed explanation or URL is welcome!
      >
      > > Thanks
      > > ACR
      >
      > Here is how I understand the \zs and \ze atoms: First, match as if the pattern
      > didn't contain them. Then, if found, move the start and end points of the
      > "found text" (which will be highlighted with Search highlight, used as the
      > value of \0 if the latter is found in the second term of a ":substitute",
      > etc.) to \zs (if present) and \ze (if present), respectively.
      >
      > -- Well, sorry for the parentheses: maybe you'll have to omit them at first
      > reading, then add them only if necessary for full details.
      >
      > \%(atom\)\@<= matches with zero length if \%(atom\) matches immediately
      > before. But it is usually slow to match, even if backtracking will only go to
      > the second nearest linebreak: use \zs instead, if possible.
      >
      > Best regards,
      > Tony.
      > --
      > "If a camel flies, no one laughs if it doesn't get very far."
      > -- Paul White
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Show all 6 messages in this topic