Buffers, Windows & Tabs
Edit multiple files with buffers, split windows, and tab pages.
Code
:e file.txt " edit a file (load into a buffer)
:badd file2.txt " add buffer without showing
:ls " list all buffers
:b N " switch to buffer N
:bn / :bp " next / previous buffer
:bd " delete (close) current buffer
" Splits (windows)
:sp file.txt " horizontal split
:vs file.txt " vertical split
Ctrl-w h/j/k/l " move between splits
Ctrl-w = " equalize split sizes
:q " close current window
:only " close all but current
" Tabs (collections of windows)
:tabnew file.txt " open file in new tab
:tabn / :tabp " next / previous tab
gt / gT " next / previous tab (normal mode)
:tabc " close tabExplanation
A buffer is an in-memory file; a window is a viewport onto a buffer; a tab is a collection of windows. Buffers persist across windows/tabs. :ls shows buffer numbers; use :b N to jump. Splits let you see multiple files; Ctrl-w + hjkl moves the cursor between splits. Tabs are not like other editors' tabs — they're layouts. Many users keep one tab with vertical splits and use :bn/:bp or fuzzy finders (fzf.vim/Telescope) to switch buffers.
More Vim Snippets
Search & Substitute
Find text with / and replace with :s, leveraging regex and ranges.
Registers (Multi-Clipboard)
Store yanks/deletes in named registers and paste from them.
Marks (Bookmarks)
Jump back to positions in a file or across files with marks.
Macros (Recorded Keystrokes)
Record a sequence of keys and replay it to automate repetitive edits.
Folding (Collapse Code)
Hide regions of code to focus on structure with fold methods.
Plugin Managers & Ecosystem
Install, configure and discover plugins with vim-plug / packer / lazy.