A List of Vim's Lists

by Noah Frederick |

The more features of Vim you’re familiar with, the easier it is to pick up new ones by making analogies to what you already know. To that end, it can be useful to examine similarly organized features together. Here, we take a look at Vim’s lists, which exhibit a certain amount of symmetry in their design.

Notes:
  • Mappings marked with an asterisk come from unimpaired.vim.
  • Many of the commands presented below have aliases that are not shown (e.g., :previous versus :Next).

Jump list

Vim records what it calls “jump” motions, motions that generally can take you to a distant location in your buffer or to a different buffer, in the jump list:

Action Command
Show jump list :ju[mps]
Previous jump <C-o>
Next jump <C-i>

Change list

Each undoable edit you make in a buffer adds an entry to the change list, which records the cursor location. You can therefore jump through the locations of the changes you’ve made:

Action Command
Show change list :changes
Jump to location of older change g;
Jump to location of newer change g,

Quickfix list

The quickfix list, generally speaking, provides a way of storing and traversing a list of locations across files. The quickfix list can be populated from the output of compilers and linters via :make, from searches with :grep, and so on.

Action Command
Open quickfix list :cope[n]
Close quickfix list :ccl[ose]
Previous location :cp[revious] / [q*
Next location :cn[ext] / ]q*
First location :cfir[st] / [Q*
Last location :cla[st] / ]Q*

Location list

The location list is a window-local quickfix list. That is, each window can have its own independent location list. There are special versions of commands, such as :lmake and :lgrep, that populate the location list instead of the global quickfix list.

Action Command
Open location list :lope[n]
Close location list :lcl[ose]
Previous location :lp[revious] / [l*
Next location :lne[xt] / ]l*
First location :lfir[st] / [L*
Last location :lla[st] / ]L*

Buffer list

The buffer list maintains a listing of all the buffers in the current editing session, including those that are hidden.

Action Command
Show buffer list :buffers / :ls
Previous buffer :bp[revious] / [b*
Next buffer :bn[ext] / ]b*
First buffer :bf[irst] / [B*
Last buffer :bl[ast] / ]B*

Argument list

The arglist is populated with the file’s specified on the command line when starting Vim, and can also be manipulated from within Vim with the :args family of commands. The arglist can be useful for collecting a bunch of files to act on, such as performing a search and replace.

Action Command
Show arg list :ar[gs]
Previous file :prev[ious] / [a*
Next file :n[ext] / ]a*
First file :fir[st] / [A*
Last file :la[st] / ]A*

Tag stack

Vim remembers each tag you jump to, for example by invoking <C-]>, and the location from which you jumped by pushing an entry onto the tag stack. By popping an entry from the stack, you are returned to your previous location.

Action Command
Show tag stack :tags
Previous tag :po[p] / <C-t>
Next tag :ta[g]

Tag match list

Every time you jump to a tag, it gets pushed onto the tag stack (see above). When there are multiple matches for a tag, however, they can be navigated through the tag match list.

Action Command
Show tag list :ts[elect]
Previous tag :tp[revious] / [t*
Next tag :tn[ext] / ]t*
First tag :tf[irst] / [T*
Last tag :tl[ast] / ]T*

Further Reading