hi Tim:
thanks for the detailed explanation and great info.
but if you look at this:
http://vim.wikia.com/wiki/VimTip1063
you will know what exactly I wanted to achieve.

basically I want to define a "generic" keybind or customer command,
to capture the matches by last :[range]g command, and do some work
based on those matched lines (split a win/buffer/tab/file and put
into it). This is really useful in the huge logs (over 300K+ lines
easily) analysis -- often you want to repeat that process based on
your demand and finally narrow down a relatively much smaller buffer/file
and really focus on that.
so you have a huge original raw file 500K, then:

1) :?pattern1?,/pattern2/g/pattern/
you finally are satisfied with the info you grabbed, then

2) with a new defined cmd like this:
"command! MyGrep execute 'normal! 0"ay0' | execute 'g//y A' | tabnew | enew | setlocal bt=nofile | put! a | nohls now with :MyGrep, ideally if there is no *range*, will got last matches and put in a neighboring tab,

3) repeat 1) on this new buffer(maybe with different range and pattern)
4) finally you got the key data in the last tab

this will work great if there is no range...

regards
ping


On 04/10/2012 08:26 PM, Tim Chase wrote:
On 04/10/12 16:42, ping wrote:
I'm trying to redirect a :[range]g matches to a new buffer, then
continue my work from there
the issue now is: it looks :g// only repeat last :global command without
the range
how do I make even repeat with the same range?

You don't mention how your range was originally defined. If it was with a visual range, you can continue to use the range without re-highlighting it visually. Also, you can use the range "*" (if "*" isn't in 'cpoptions') if you want to be lazy and not retype "'<,'>", so you could write

  :'<,'>g/foo/Frob(getline('.'))

and then type

  :*g/baz/Bort(getline('.'))

which you can read about at

  :help :*
  :help cpo-star

Otherwise, I'm not sure Vim has a built-in way to repeat an arbitrary range, but you do have a command history you can access with the up-arrow if you want to scroll back; or you can use the command-window by typing "q:" (or, if you're in the middle of typing a command, you can use control+F)

  :help c_<up>
  :help q:

this looks really useful if it can be implemented...

I'm not sure there's great utility to adding such functionality as

1) there's not great cause to reuse ranges, and

2) those cases you want to reuse a range, usually it's easiest to pull it out of the command history and edit it accordingly, or it's the last-highlighted range for which the "*" works as described above.

-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

Reply via email to