Step 5 of 9

12. Windows

The most important thing to remember

If you remember one mapping for window management, make it this one: <C-w> (control-W) in normal mode. It’s the prefix for practically all window operations in Vim: creating splits (<C-w>s, <C-w>v), closing them (<C-w>c), navigating between windows, moving them around, resizing them… basically everything you’ll ever need.

One warning before you try it: on some operating systems <C-w> closes the current browser tab — pressing it here could dump you out of the lesson! So inside the embedded editor we’ll map the (otherwise safe) W key to do <C-w>’s job: :nnoremap W <C-w>. Remember though — in real Vim, the binding to burn into muscle memory is <C-w> itself.

Work through the checklist: set up the map, then create and close some windows with it.

  1. Map W to stand in for <C-w> In this embedded editor, W will do everything <C-w> does, safely out of your browser's reach — type :nnoremap W <C-w> and hit Enter.
  2. Open a horizontal split with Ws In real Vim, this is <C-w>s — press W then s.
  3. Open a vertical split with Wv Real Vim's <C-w>v — press W then v.
  4. Close a window with Wc Press W then c — real Vim's <C-w>c.
Map W to stand in for <C-w> In this embedded editor, W will do everything <C-w> does, safely out of your browser's reach — type :nnoremap W <C-w> and hit Enter.

Next: Open a horizontal split with Ws

Loading editor…