How do I quickly navigate quickfix entries, buffers, and toggle options with bracket keys?
Answer
]q and [q
Explanation
The vim-unimpaired plugin by Tim Pope provides pairs of bracket mappings for common navigation and toggling tasks. Instead of typing :cnext or :cprev to navigate quickfix items, you simply press ]q and [q. The convention is consistent: ] goes forward/next and [ goes backward/previous.
How it works
Navigation pairs:
[q/]q— previous/next quickfix entry (:cprevious/:cnext)[Q/]Q— first/last quickfix entry (:cfirst/:clast)[b/]b— previous/next buffer (:bprevious/:bnext)[l/]l— previous/next location list entry (:lprevious/:lnext)[a/]a— previous/next argument (:previous/:next)[t/]t— previous/next tag (:tprevious/:tnext)
Option toggling with yo prefix:
yoh— togglehlsearchyon— togglenumberyow— togglewrapyos— togglespell
Example
After running :vimgrep /TODO/ **/*.js to populate the quickfix list, navigate results with:
]q → jump to next TODO match
[q → jump to previous TODO match
]Q → jump to last TODO match
[Q → jump to first TODO match
Tips
- Install with any plugin manager:
Plug 'tpope/vim-unimpaired' - Line manipulation mappings are also included:
[e/]eto move lines up/down,[<Space>/]<Space>to add blank lines - The bracket convention is easy to remember:
[always means previous/up,]always means next/down