On Thursday, June 14, 2012 4:17:55 PM UTC-5, ping wrote:
> 
>     to be more precise , I want to extract only those adjacent lines
>     like following, 
> 
>     
> 
>     <font size="+1"><font face="monospace">    classifier-group
>         jnpr-VIDEO-TRAFFIC entry 2
> 
>               0 packets, 0 bytes</font></font>
> 

Thank you for finally being precise.

Now we can answer your question.

First, is there any way you can stop using the obnoxiously formatted HTML
emails? The list convention is plaintext, and the large font size is
especially jarring.

Anyway...you learned that a :g command only runs a command on the first line
of a match, if you specify a multi-line pattern. But, you want to specify
which lines to act on based on a multi-line match; i.e., a line with
"classifier-group" followed by a line with "X packets, Y bytes" where X and
Y are both non-zero numbers. So you will need to use a multi-line regex, and
also the trick shown by others in this thread, to specify a range for the
command which :g runs on each matching first line, so that you can print
multiple lines starting at each first line of your multi-line regex.

I think, this should do what you want:

  :g#classifier-group\>.*\n\s*[1-9]\d* packets, [1-9]\d* bytes#.,+1p

Note carefully what this does: it matches a multi-line pattern of exactly
two lines with the characteristics you describe, and runs the "print"
command on the first line that matches, plus the next line (thus, both
matched lines).

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

Reply via email to