3

I'm relatively new to Vim. I've just installed EasyGrep but can't figure out how to open the files listed in the Quickfix List when I do a search. I can cycle through files containing a matching word using :cn or open a file by double-clicking with my mouse but when I press <Enter> nothing happens. I've also tried go and t but neither of these are working.

Can anyone help?!

Thanks in advance

6
  • 6
    Read :h quickfix and :h quickref. Good luck! :-)
    – ryuichiro
    Commented Nov 8, 2015 at 18:27
  • Thanks @ryuichiro ! I have found lots out here that's really useful however. Apparently pressing <Enter> should open the file under the cursor but it doesn't :/ 'In the quickfix window, each line is one error. The line number is equal to the error number. You can use ":.cc" to jump to the error under the cursor. Hitting the <Enter> key or double-clicking the mouse on a line has the same effect.' Commented Nov 11, 2015 at 15:54
  • 1
    Hm, it is possible that you enter is mapped to something. You can check it by :verbose map <CR>.
    – ryuichiro
    Commented Nov 11, 2015 at 15:59
  • That was it! Thanks, I had it mapped to make a new line: nmap <CR> o<Esc> Commented Nov 11, 2015 at 16:38
  • If you have a mapping for <CR> that you want to keep, except for when you are in quickfix, you can use autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR> in your ~/.vimrc to undefine the mapping for quickfix as pointed out here
    – Wolfson
    Commented May 14, 2020 at 8:44

1 Answer 1

7

As already mentioned by @ryuichiro, and then quoted by @Alistair Colling, the quickfix documentation (:h quickfix and :hquickref) provides an answer for how to open files within a quickfix list:

You can use :.cc to jump to the error under the cursor. Hitting the <Enter> key or double-clicking the mouse on a line has the same effect. The file containing the error is opened in the window above the quickfix window.

Make sure that your <Enter> Key (<CR>) is not mapped so that it properly works. As already mentioned by @ryuichiro, this can be checked with

:verbose map <CR>

If you have a global mapping for <CR> (e.g. in my case a mapping from the NERDtree plugin), you can undefine it just for when you are within a quickfix list based on adding the following line to your ~/.vimrc as explained here:

autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>

Not the answer you're looking for? Browse other questions tagged or ask your own question.