:buffer 3 " Switch to buffer 3:b 3 " Short form:b main.lua " Switch by name (partial match works):b mai<Tab> " Use tab completion
Navigation
:bnext " Next buffer:bn " Short form:bprevious " Previous buffer:bp " Short form:bfirst " First buffer:blast " Last buffer:bmodified " Next modified buffer:bm " Short form
Quick Switch
CTRL-^ " Toggle between current and alternate buffer:b# " Same as CTRL-^3 CTRL-^ " Switch to buffer 3
The alternate buffer (#) is the previously edited buffer. Use CTRL-^ to quickly switch between two files!
:badd file.txt " Add file to buffer list:bdelete 3 " Delete buffer 3:bd 3 " Short form:bd main.lua " Delete by name:bd! " Force delete (discard changes):1,3bd " Delete buffers 1-3:%bd " Delete all buffers
:bunload 3 " Unload buffer (keep in list):bun 3 " Short form:bwipeout 3 " Completely remove buffer:bw 3 " Short form (deletes everything)
bwipeout removes all marks, options, and mappings. Use with caution!
:bufdo set nu " Execute command in all buffers:bufdo %s/foo/bar/g | update " Search and replace in all:wall " Write all changed buffers:qall " Quit all
:split " Split current window horizontally:sp " Short form:split file.txt " Split and edit file.txt:10split " Split with 10 lines heightCTRL-W s " Normal mode split
2
Vertical Split
:vsplit " Split vertically:vs " Short form:vsplit file.txt " Split and edit file.txt:30vsplit " Split with 30 columns widthCTRL-W v " Normal mode split
3
New Window
:new " New window with empty buffer:vnew " Vertical new windowCTRL-W n " Normal mode new window
Use :split for horizontal (one above the other) and :vsplit for vertical (side by side).
CTRL-W h " Move to window on the leftCTRL-W j " Move to window belowCTRL-W k " Move to window aboveCTRL-W l " Move to window on the rightCTRL-W <Left> " Alternative: arrow keysCTRL-W <Down>CTRL-W <Up>CTRL-W <Right>
CTRL-W w " Next window (wrap around)CTRL-W W " Previous windowCTRL-W t " Top-left windowCTRL-W b " Bottom-right windowCTRL-W p " Previous (last accessed) window3 CTRL-W w " Go to window number 3
:quit " Quit current window:q " Short formCTRL-W q " Normal mode quitCTRL-W c " Close current window:close " Close current window:only " Close all other windowsCTRL-W o " Normal mode only
Closing the last window for a buffer doesn’t delete the buffer — it becomes hidden (if 'hidden' is set) or inactive.
CTRL-W r " Rotate windows downward/rightwardCTRL-W R " Rotate windows upward/leftward
CTRL-W x " Exchange with next window2 CTRL-W x " Exchange with window 2
CTRL-W H " Move window to far leftCTRL-W J " Move window to bottomCTRL-W K " Move window to topCTRL-W L " Move window to far rightCTRL-W T " Move window to new tab
" Set minimum window sizes:set winminheight=0 " Minimum height (0 = just status line):set winminwidth=0 " Minimum width" Automatic window sizing:set winheight=999 " Always maximize current window height:set equalalways " Auto-resize windows equally:set splitbelow " Open new splits below:set splitright " Open new splits to the right
:tabnext " Next tab:tabn " Short formgt " Normal mode next tab:tabprevious " Previous tab:tabp " Short formgT " Normal mode previous tab3gt " Go to tab 3
:tabfirst " First tab:tabl " Last tab:tab 3 " Go to tab 3
:tabclose " Close current tab:tabc " Short form:tabonly " Close all other tabs:tabo " Short form:tabmove 0 " Move tab to position 0 (first):tabmove " Move tab to end:tabmove +1 " Move tab one position right:tabmove -1 " Move tab one position left:tabs " List all tabs:tabdo %s/foo/bar/g " Execute command in all tabs