On Nov 18, 1:55 am, Gary Johnson <garyj...@spocom.com> wrote:
> On 2009-11-17, Peng Yu wrote:
>
>
>
> > $grep-H -n if /etc/profile>/tmp/grep_output.txt
> > $ cat /tmp/grep_output.txt
> > /etc/profile:4:if [ -d /etc/profile.d ]; then
> > /etc/profile:6:    if [ -r $i ]; then
> > /etc/profile:13:if [ "$PS1" ]; then
> > /etc/profile:14:  if [ "$BASH" ]; then
> > /etc/profile:16:    if [ -f /etc/bash.bashrc ]; then
> > /etc/profile:20:    if [ "`id -u`" -eq 0 ]; then
> > $ gvim /tmp/grep_output.txt
>
> > Now, I want to double click a line in 'grep_output.txt' so that gvim
> > will automatically bring me the corresponding file and line. I'm
> > wondering how to do so.
>
> > P.S. Similar things can be done when I use ':make', in which cases
> > gvim can bring me to the error line.
>
> As usual, there are several ways to do this.  The easiest is to
> dispense with the temporary file and invoke yourgrepcommand from
> within vim:
>
>     :grepif /etc/profile
>
> The results go into the quickfix list just as they do when you
> execute ":make".  See
>
>     :helpgrep
>
> Vim takes care of supplying the right arguments togrepand
> constructing the command line so that you don't need to supply the
> -H or -n options yourself.
>
> If you already have the temporary file loaded into a buffer in vim,
> you can move the cursor to the start of any of the lines and type
>
>     gF
>
> to jump to that file and line number.
>
>     ^WF
>
> does the same but opens the file in a new window.  See
>
>     :help gF
>     :help CTRL-W_F
>
> A third way, that uses both the temporary file and the quickfix
> list, is to open your temporary file like this:
>
>     gvim --cmd 'let &efm=&gfm' -q /tmp/grep_output.txt

I want to start with gvim as if ':cope' is typed. Would you please let
me know how to modify the above command?

> See
>
>     :help -q
>
> Since the -q option uses the 'errorformat' ('efm') to parse the
> error file, and since 'errorformat' matches the output of a
> compiler, not ofgrep, you need to assign the value of
> 'grepformat' ('gfm') to 'errorformat' before opening an error file
> containing the output of agrepcommand.
>
> For other ways to get data into the quickfix list, see
>
>     :help :cf
>     :help :cb
>
> As for jumping to a line by double clicking on the file name and
> line number, see
>
>     :help double-click
>
> for an example of mapping a double click to the operation of your
> choice.
>
> HTH,
> Gary
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to