Vim quickfix avoids buffer changes

I use vimgrepc cwto open search results in a buffer quickfix. Each time I select a line in the quickFix list, the cursor moves to a new file buffer. How can I avoid this and always keep the cursor in the quickFix list?

+3
source share
2 answers

Assuming that you use <CR>to "select a line in the quick access list", you can simply reassign <CR>in the quick fix window to return to the previous window after switching to the corresponding line.

Make sure you have one filetype plugin indent onand add the line below to ~/.vim/ftplugin/qf.vim:

nnoremap <buffer> <CR> <CR><C-w>p
+3
source

:cnext :cprevious <C-w>p ( ).

, . <Leader>cn <Leader>cp, :

nnoremap <silent> <Leader>cn :cnext<CR><C-w>p
nnoremap <silent> <Leader>cp :cprevious<CR><C-w>p
0

All Articles