Vim 101: Windows

Split windows

Windows are a viewport on a buffer. Opening Vim displays a single window, which is how most text editors generally appear. However, the real power of Vim, and something people miss out on in a lot of editors, is multiple windows. Windows can be split horizontally and vertically as needed, and then moved, resized, and closed.

Window commands start with CTRL-W, which makes it pretty easy to learn the basic commands:

  • CTRL-W s (window split): Split the current window horizontally
  • CTRL-W v (window vertical): Split the current window vertical
  • CTRL-W w: Move to the next window, CTRL-W W will move to the previous one
  • CTRL-W k: Move the cursor up (hjkl work as expected)

To get help on window cursor movement and see all of the other commands, type :help window-move-cursor.

Window Management

Windows can be closed with CTRL-W q, and closing the last window will exit Vim.

Windows can be vertically resized by typing CTRL-W - and CTRL-W + -- this is sometimes useful when working with a lot of windows, and the current file demands more attention than the rest. Horizontal resizing uses < and >, which is easy to remember. Typing CTRL-W | makes the current window as wide as possible, and CTRL-W _ does the same thing for the height.

The resize commands accept a numerical argument, so typing CTRL-W 9+ would increase the current window by 9 lines.

Sometimes windows need to be moved. Movement uses the standard hjkl keys, but capitalised instead:

  • CTRL-W H: Move the current window to the left, using the full width
  • CTRL-W J: Move the current window to the bottom, using the full height
  • CTRL-W K: Move the current window to the top, using the full width
  • CTRL-W L: Move the current window to the right, using the full height

I don't often use these commands, but one related command I do use is CTRL-W T which opens the current window in a new tab. This can be useful when the buffer becomes too long or complex and deserves its own tab.


If Vim has been set up to use a mouse, even in text mode, then windows can be resized by clicking and dragging its status line.

blog comments powered by Disqus