Skip to content

Instantly share code, notes, and snippets.

@slarwise
Last active July 16, 2021 20:17
Show Gist options
  • Save slarwise/d0b7248b8f6837a4ecc254206a8ac2b2 to your computer and use it in GitHub Desktop.
Save slarwise/d0b7248b8f6837a4ecc254206a8ac2b2 to your computer and use it in GitHub Desktop.
Vim quickfix options, mappings and commands
" Open the quickfix window in a horizontal split at the bottom
" The height is the number of quickfix items (if it fits)
command! Copen execute "cclose | botright copen " . len(getqflist())
" Open the quickfix window in a vertical split to the left
command! Vcopen execute "cclose | copen | wincmd H"
" Add the cfilter plugin to enable the :Cfilter command
" This command lets you filter the quickfix list
packadd cfilter
" Make the quickfix window behave like a regular window when resizing
" E.g. <C-W>= will resize the quickfix window to the same size as the other windows
setlocal nowinfixheight
setlocal nowinfixwidth
" Open the quickfix item under the cursor but stay in the quickfix window
" zt adjusts the window so that the line is at the top
nnoremap <buffer> p <CR>zt<C-w>p
" Open the quickfix item below but stay in the quickfix window
nnoremap <buffer> <C-j> j<CR>zt<C-w>p
" Open the quickfix item above but stay in the quickfix window
nnoremap <buffer> <C-k> k<CR>zt<C-w>p
@slarwise
Copy link
Author

slarwise commented Jul 16, 2021

Typical workflow:

:grep some_function . -r
:Vcopen
" Use <C-J> and <C-K> to explore the found matches without leaving the quickfix window

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment