vimtricks.wiki Concise Vim tricks, one at a time.

How do I preview quickfix entries without leaving the quickfix window?

Answer

<C-w>z or :pclose

Explanation

The preview window shows file contents temporarily without switching your editing context. In the quickfix window, you can preview entries to inspect matches before jumping to them, keeping your current position intact.

How it works

  • :pedit {file} — open a file in the preview window
  • :psearch {pattern} — search and show result in preview window
  • <CR> in quickfix — jumps to the entry (leaves quickfix)
  • <C-w>} — preview the tag under cursor
  • <C-w>z or :pclose — close the preview window

Example

" After :vimgrep, open quickfix
:copen

" Navigate entries and preview
:cc 3    " jump to entry 3
:pedit +42 src/main.py  " preview line 42
+---------------------------+
| Preview: src/main.py:42   |  ← preview window
| function handle_request() |
+---------------------------+
| src/main.py|42| match     |  ← quickfix window
| src/util.py|15| match     |
+---------------------------+

Tips

  • Set previewheight to control preview window size: :set previewheight=15
  • Only one preview window can exist at a time — opening another replaces it
  • Use <C-w>P to jump to the preview window, <C-w>p to jump back
  • Neovim's LSP uses the preview window for hover documentation

Next

How do I return to normal mode from absolutely any mode in Vim?