Saturday, January 26, 2013

Re: does vi has a funtion like "grep -v"?

On 1/26/2013 11:38 AM, Ben Fritz wrote:
> On Saturday, January 26, 2013 10:34:32 AM UTC-6, ping wrote:
>> Why not just use external grep in vim if that's what you want?
>>
>> :[range]!grep -v
>>
>>
> This will replace all the lines in [range] with the output of !grep. I don't think the OP wanted to DELETE the lines, just find them.
>
> The better way to invoke external grep for searching from Vim is with Vim's :grep command, which invokes 'grepprg' and then populates the quickfix list. 'grepprg' by default just uses grep.
>
that's a good point, but from what my experiences (test, errors), in an
attempt to find the solution for this desire , I really think the
external grep way is the most efficient.
reason:

1) most of time , I just want to quicky find out the wanted or
not-wanted (-v) lines per keyword
2) :[range]!grep [-v] will re-use whatever your skills of standard unix
tool : grep
3) if you don't want to "replace" but to "display", you can use
:[range]w !grep [-v]
4) but the :[range]w ! way doesn't know "scale", as the new found texts
won't but put in a buffer by default, (unless redirected), so you can't
re-fine your research based on the result.
5) even if you don't want to "replace" the original texts, you can
easily go back via "u"
6) and if you like what you get, but want to even re-define a new
search based on it, just repeat the whole process recursively.
7) and once done, always just recover back to original text via some
'u'ndos.

I also like the vimgrep coming with the fancy quickfix list, but that
looks a better usage scenario when I need to search from a bunch of
files (under a common dir ).

just my 2 cents.

regards
ping

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