On 08/04/10 14:21, Jim Green wrote:
Hi,
when I examines the logs I need to do :g/regex to get relevant texts
and vim splits a region shows the result with
Press ENTER or type command to continue
If I accidentally type sth this region will go away, so I normally use
external program grep to pipe the result to a file and then examine.
If I could get the :g/regex command result to a buffer that would be
fantastic.
I don't know of any stock way to do it, but you can use some
workarounds such as:
1) copy the entire buffer into a new window and delete the lines
you don't want:
:%y
:new
:0p
:v/regex/d
2) Accumulate them in a register and then paste that register in
a new window, something like
:let @a=''|g/regex/y A
3) use :redir to capture the output into a variable (so you don't
tromp a register) such as:
:redir => some_variable
:g/regex
:redir END
:new
:0put=some_variable
4) use :vimgrep to gather all the matching locations in the
quickfix window. It's not exactly what you describe wanting, but
makes jumping to them pretty easy:
:vimgrep /regex/ %
:copen
depending on what you want to do with the results.
I'm sure there are other options, and any of them can be mapped
to shorten them or have a custom command created from them.
Hope this gives you some ideas.
-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