← All lessons

11. Buffers

Step 5 of 6

Jumping back and forth

Most of the time when we’re working with multiple files, we’re jumping back and forth between just two files at any given time. For example, we might be switching between two source code files, or we might be switching between a LaTeX document and a bibliography. Vim has a tool that can help us here.

It’s called the “alternate file”. When you switch buffers, Vim keeps track of the buffer you were in last so that we can switch back to it quickly. The keymap for jumping to the alternate file is <C-^> — that’s hitting the 6 key on your keyboard whilst holding control.

Let’s try this out. In the editor, open foo.txt and bar.txt with either the :e command or with :args *.txt. Then:

Loading editor…