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.
- Mappings marked with an asterisk come from unimpaired.vim.
- Many of the commands presented below have aliases that are not shown (e.g.,
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:
|Show jump list||:ju[mps]|
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:
|Show change list||:changes|
|Jump to location of older change||g;|
|Jump to location of newer change||g,|
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.
|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*|
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
:lgrep, that populate the location list instead of the global quickfix list.
|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*|
The buffer list maintains a listing of all the buffers in the current editing session, including those that are hidden.
|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*|
The arglist is populated with the file paths 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.
|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*|
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.
|Show tag stack||:tags|
|Previous tag||:po[p] / <C-t>|
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.
|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*|