Quantcast

Using the quickfix window without losing focus

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Using the quickfix window without losing focus

Jonathan del Strother
Hi,
I'm using fugitive's :Ggrep (a git-based wrapper around vimgrep) to
scan for occurrences of a word in my project, viewing them in the
quickfix window.  I end up with quite a few results, and it's not
obvious which file I'm interested in without opening the file.  When I
hit enter in the quickfix window, it opens that file and moves the
cursor focus to the new buffer.  Is it possible to keep the focus in
the quickfix window, so I can just hit enter, realise it's not the
file I'm looking for, hit down/enter, and repeat?

--
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Using the quickfix window without losing focus

Karthick Gururaj
On Mon, May 14, 2012 at 1:34 PM, Jonathan del Strother
<[hidden email]> wrote:

>
> Hi,
> I'm using fugitive's :Ggrep (a git-based wrapper around vimgrep) to
> scan for occurrences of a word in my project, viewing them in the
> quickfix window.  I end up with quite a few results, and it's not
> obvious which file I'm interested in without opening the file.  When I
> hit enter in the quickfix window, it opens that file and moves the
> cursor focus to the new buffer.  Is it possible to keep the focus in
> the quickfix window, so I can just hit enter, realise it's not the
> file I'm looking for, hit down/enter, and repeat?
You can map the <CR> key?
E.g:

:noremap <CR> <CR><C-W><C-P>

Or,
:noremap <CR> <CR><C-W><C-P>j
(saves one more keystroke).

Better to put that in autocmd for filetype as 'qf'.

(disclaimer: works for quickfix, haven't used :Ggrep).

--
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Using the quickfix window without losing focus

John Beckett-2
Karthick Gururaj wrote:
>
> :noremap <CR> <CR><C-W><C-P>

Yes, however it should be a buffer mapping, and you might like
to use a different key, such as o to open the file:

nnoremap <buffer> o <CR><C-W>p

Put the above line in file ~/.vim/after/ftplugin/qf.vim (Unix)
or file $HOME\vimfiles\after\ftplugin\qf.vim (Windows).
Create any missing directories.

John

--
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Using the quickfix window without losing focus

Jonathan del Strother
On 14 May 2012 11:43, John Beckett <[hidden email]> wrote:

> Karthick Gururaj wrote:
>>
>> :noremap <CR> <CR><C-W><C-P>
>
> Yes, however it should be a buffer mapping, and you might like
> to use a different key, such as o to open the file:
>
> nnoremap <buffer> o <CR><C-W>p
>
> Put the above line in file ~/.vim/after/ftplugin/qf.vim (Unix)

Nifty, thanks.

--
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Using the quickfix window without losing focus

Ben Fritz
In reply to this post by Jonathan del Strother
On Monday, May 14, 2012 3:04:33 AM UTC-5, Jonathan del Strother wrote:
> Hi,
> I'm using fugitive's :Ggrep (a git-based wrapper around vimgrep) to
> scan for occurrences of a word in my project, viewing them in the
> quickfix window.  I end up with quite a few results, and it's not
> obvious which file I'm interested in without opening the file.  When I
> hit enter in the quickfix window, it opens that file and moves the
> cursor focus to the new buffer.  Is it possible to keep the focus in
> the quickfix window, so I can just hit enter, realise it's not the
> file I'm looking for, hit down/enter, and repeat?

You can navigate between entries without leaving the quickfix list using :cnext and :cprev commands. Both of these take a count if you want to skip a few entries. But going to a specific entry in the middle of the list somewhere would be difficult without a mapping-based solution like John and Karthick gave.

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