Hi,
On Mon, Feb 13, 2017 at 2:13 AM, was4444 <[email protected]> wrote:
> Thanks @chrisbra, I did not even hear of quickfix/location, I need some more
> googling and reading.
>
> I used to:
>
> git grep -n foo
> no results found or not what I expect, then git grep -n bar
> use vim for a quick view on a certain line
>
> It seems that quickfix/location requires an already opened vim buffer?
>
Different quickfix/location list commands are available to process the
output from a command. Some of them are listed below:
1. Redirect the output from a command to a file and pass it onto Vim.
$ grep -Hn abc *.log > output.txt
$ vim -q output.txt
2. Run the command directly from Vim and populate the quickfix list.
$ vim
:cexpr system('grep -Hn abc *.log')
3. Read the output of the command into a Vim buffer (or paste the
output of the command into a buffer) and populate the quickfix list.
Note that you can use an unnamed/scratch buffer for this.
$ vim
:r! grep -Hn abc *.log
:cgetbuffer
The above 'cgetbuffer' command processes the entire buffer. You can
also process only selected lines by passing a range to the command.
4. Use the ":grep" command to invoke an external command
set in the 'grepprg' option.
$ vim
:grep -Hn abc *.log
5. Use the internal ":vimgrep" command:
$ vim
:vimgrep abc *.log
Once the quickfix list is populated, you can use the various quickfix commands
to browse the result.
There are also similar commands available for using the location list.
- Yegappan
> And how to jump to, for example, the 5th(and most of time it's hard to tell
> vim the number) result? Or, if no one expected, how can I just close it?
>
> $ vim -c ":grep blabla *.log"
>
> grep.log:1:1 blabla
> grep.log:2:2 blabla
> grep.log:3:3 blabla
> grep.log:4:4 blabla
> grep.log:5:5 blabla
> grep.log:6:6 blabla
> grep.log:7:7 blabla
> grep.log:8:8 blabla
> grep.log:9:9 blabla
> grep.log:10:10 blabla
>
> Press ENTER or type command to continue
>
--
--
You received this message from the "vim_dev" 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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.