window
: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.
:vsplit [file] :split [file] :tabnew [file] (command mode) Variations
| Keystroke | Effect |
|---|---|
| :vnew | Vertical split with a new empty buffer |
| :new | Horizontal split with a new empty buffer |
| :tabclose | Close the current tab page |
| gt / gT | Cycle to next / previous tab |
Examples
:vsp src/app.js Open src/app.js in a vertical split on the right
:sp Split current window horizontally, both showing same buffer
:tabnew README.md Open README.md in a new tab
Gotcha
Tabs in Vim are 'workspaces' of splits, NOT a list of open files like in modern editors — you probably want buffers (:b, :ls) rather than tabs.
Related
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.
:e
Edit (open) a file in the current window. With no argument, :e reloads the current file from disk — handy after external changes.
:w / :saveas
Write (save) the current buffer to disk. Without an argument :w saves to the current file; with an argument it writes a copy without switching buffers. Use :saveas when you want to rename the buffer to the new file and keep editing that one.