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

How do I use bracket mappings for paired operations?

Answer

[q, ]q, [b, ]b (vim-unimpaired)

Explanation

vim-unimpaired by Tim Pope provides consistent bracket mappings for navigating paired items like quickfix entries, buffers, and more.

How it works

  • ]q / [q — next/prev quickfix entry (:cnext/:cprev)
  • ]b / [b — next/prev buffer (:bnext/:bprev)
  • ]l / [l — next/prev location list entry
  • ]f / [f — next/prev file in directory
  • ]<Space> / [<Space> — add blank line below/above

Example

After :vimgrep /TODO/ **/*.py, use ]q and [q to navigate through results.

Tips

  • Install: Plug 'tpope/vim-unimpaired'
  • ]e / [e exchange (move) line down/up
  • yos toggles spell checking, yon toggles numbers
  • ]x{motion} XML-encodes, [x{motion} XML-decodes
  • Consistent mnemonic: ] is forward/down, [ is backward/up

Next

How do you yank a single word into a named register?