vim quickfix avoid buffer change

后端 未结 2 1841
抹茶落季
抹茶落季 2021-01-13 07:57

I\'m using vimgrep with cw to open the search results in the quickfix buffer. Every time I select a line in the quickFix list the curs

相关标签:
2条回答
  • 2021-01-13 08:20

    You can use :cnext and :cprevious combined with a <C-w>p (focus on previous window).

    To bind them to e.g. <Leader>cn and <Leader>cp, you could do:

    nnoremap <silent> <Leader>cn :cnext<CR><C-w>p
    nnoremap <silent> <Leader>cp :cprevious<CR><C-w>p
    
    0 讨论(0)
  • 2021-01-13 08:34

    Assuming you are using <CR> to "select a line in the quickFix list", you can simply remap <CR> in the quickfix window so that you come back to the previous window after jumping to the matching line.

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

    nnoremap <buffer> <CR> <CR><C-w>p
    
    0 讨论(0)
提交回复
热议问题