Step 1 of 9

12. Windows

Windows are a viewport into a buffer

Before we dive in, a small warning: Vim’s system of buffers, windows, and tabs is probably quite different from what you’re used to in other text editors. Try to forget what you already know about how files/windows/tabs work in your current editor — reconciling the two will only make things harder. And as you learn more, you’ll realize that Vim does it better.

Recall from the last lesson: a buffer is the in-memory text of a file, and Vim can hold many of them at once. Closely related is the idea of windows. A window is a viewport into a single buffer — the “thing” you’re looking through to see the contents of your file. If you can see text on the screen — congratulations! You’re looking at a buffer through a window.

Up until now we’ve worked with one window filling the whole screen, but Vim can divide the screen into many windows, each peering into a different buffer. You can use this to keep multiple files visible at the same time!

The editor has exercise.txt open, and there’s another file on disk called myfile. Work through the checklist: opening myfile in a new (horizontally split) window puts both files on screen at once, one on top of the other.

  1. Open myfile in a split Type :split myfile and hit Enter — a second window opens on top, peering into myfile.
Open myfile in a split Type :split myfile and hit Enter — a second window opens on top, peering into myfile.

Last one — goal check runs when it's done

Loading editor…