>> :let @a=''|g/^\(\%^\|\n\)\(.\+\n\)*.*Regexp/;'}y A
>
> I tried to break out the pieces.
> Does the ';' mean perform another search?
>
> :let @a=''|g/^\(\%^\|\n\)\(.\+\n\)*.*foo/;'}y A
>
> \%^ Matches start of the file
> When matching with a string matches the start of the string
> example, to find the first "VIM" in a file: /\%^\_.\{-}\zsVIM
> \| A pattern is one or more branches
> ; Perform another search
> '{ `{ To the start of the current paragraph
You're close...it could be clarified/expanded by putting a "." in 
front of the ";" which delimits a range
:help :;
so the :g searches for a paragraph-break or the start of file, 
followed by zero-or-more lines containing at least one character 
(not a paragraph break), followed by a line containing the 
"Regexp" you're searching for.  It then, starting on the matching 
line (the one with either the start-of-file or paragraph break), 
a range is created through the next paragraph break ("'}") and 
yanked-appending into register "a".
  g/           On every line matching this pattern
  ^             a start-of-line
  \(            where either of these two branches match:
   \%^           the start-of-file
   \|            or
   \n            a newline (thus this is a blank line)
  \)            (end of the branches)
  \(.\+\n\)*    followed by 0+ lines containing 1+ characters
  .*foo         followed by stuff matching up to "foo" (your RE)
  /           Perform the following action
              (implicit current line as the start-of-range)
  ;           through
'}           the next-paragraph mark (either a blank line
              or the EOF)
y A          Yank the range into register "a", appending
Hope that helps shed some light on the opacity of the expression.
-tim
-- 
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
No comments:
Post a Comment