Editing multiple documents in vim: Using vim windows
We’ve talked about using buffers to edit multiple documents in vim. Each file lives in a buffer which, in turn, lives in it’s own tab page, rather like a tab in a web browser. But sometimes I want to view one file while editing another, and it would be handy to have both files in the same screen at once. To support that, vim gives us windows.
To split the screen into multiple windows in vim, switch to command mode and run
:split or control-w followed by s. This will split the screen into two windows, each containing a copy of the file that was in the original screen. Running
:split again will create a third pane, and so on.
If you want to open the new pane with a different file, run
:split <filename>. This will open a new window with the other file loaded inside. To open a window with a new, blank file, run
:new or control-w n.
The active window can be resized with with the command
:resize # or
z#, where the # sign is the number of lines high that the window should be.
To move up and down among the visible windows use control-w k and control-w j respectively. To close the selected window, run
:close or press control-w c.
There are actually many commands to manipulate buffers and windows in vim. These are the basics and will get you through most common tasks. To learn more, go to vim’s command mode and run
Be seeing you.
One thought on “Waits at the window wearing the face that she keeps in a jar by the door…”