Commands for opening new windows
There are lots of ways to open a new window in Vim. Most of the time, opening a new window involves splitting the current window in two — either horizontally (two windows on top of each other) or vertically (two windows side-by-side). This is why you’ll sometimes hear folks referring to windows as “splits” in the community.
The most basic way of opening a new window is using the split commands. The two simplest are :split (for horizontal splits) and :vsplit (for vertical splits). We had a brief interaction with the :split command in the last section, but now let’s dive a bit deeper.
Both :split and :vsplit accept a filename, which tells Vim to:
- Load the given file into a new buffer.
- Split the current window into two.
- Open the buffer in the new window.
In the editor, the file that’s currently open is called demo. On the filesystem, there are three other files called a.txt, b.txt, and c.txt. Using a combination of :split and :vsplit commands, try opening some new windows!