Skip to content
Vim

Buffers, Windows & Tabs

Edit multiple files with buffers, split windows, and tab pages.

By EZ4Code Team
bufferwindowtabsplit

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 tab

Explanation

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