window
Ctrl-W
Ctrl-W is the prefix for every window-management command. Follow it with h/j/k/l to move between splits, with =/_/| to resize, or with c/o to close windows.
<C-w>{key} (normal mode) Variations
| Keystroke | Effect |
|---|---|
| <C-w>h/j/k/l | Move cursor to the split in that direction |
| <C-w>w | Cycle to the next window |
| <C-w>= | Equalize all window sizes |
| <C-w>o | Close every window except the current one |
| <C-w>c | Close the current window |
| <C-w>_ / <C-w>| | Maximize the current window vertically / horizontally |
Examples
<C-w>l Jump to the split to the right
<C-w>o Turn a busy layout back into a single window
10<C-w>> Widen the current window by 10 columns
Gotcha
Ctrl-W in INSERT mode deletes the previous word — not a window command. Escape first.
Related
:vsplit / :split / :tabnew
:split (or :sp) opens a horizontal split, :vsplit (:vsp) a vertical split, :tabnew a new tab page. All three optionally take a filename to open in the new pane/tab.
Escape
Leaves the current mode and returns to normal mode. Vim is modal — most of the time you want to be in normal mode; if you're not sure what mode you're in, mash Escape.
:e
Edit (open) a file in the current window. With no argument, :e reloads the current file from disk — handy after external changes.