Site Tools


wiki:neovim-buffers-windows-tabs

Neovim Buffers, Windows, and Tabs

Buffers are files loaded in memory. Windows are views onto buffers (you can split windows). Tabs are collections of windows. Understanding the three is key to managing large projects.

Buffers

:e file — open file in buffer (or create if new). :enew — new blank buffer. :bn — next buffer, :bp — previous buffer.

:bd — delete buffer (close file). :bdelete or :bwipe for variants. :ls or :buffers — list all open buffers.

:e newfile.txt       " open file
:enew                " new blank buffer
:bn                  " next buffer
:bp                  " previous buffer
:bd                  " close buffer

Buffers are independent of windows — closing a window doesn't close the buffer.

Windows

:split — split window horizontally (same file). :vsplit — split vertically. :new — new buffer in horizontal split, :vnew — vertical.

Ctrl+W then navigation: Ctrl+W h/j/k/l — move to left/down/up/right window. Ctrl+W w — cycle through windows.

Ctrl+W n — new window below, Ctrl+W v — new window to right. Ctrl+W c — close window.

Resize: Ctrl+W + — increase height, Ctrl+W - — decrease, Ctrl+W > — increase width, Ctrl+W < — decrease.

:split          " split horizontal
:vsplit         " split vertical
Ctrl+W h        " move to left window
Ctrl+W j        " move to below window
Ctrl+W +        " increase window height
Ctrl+W =        " equalize all windows

Tabs

:tabnew — new tab (empty buffer). :tabnew file — new tab with file. gt — next tab, gT — previous tab.

:tabclose — close current tab, :tabnext N — jump to tab N (numbered from 1).

Tabs are useful for organizing unrelated work (one tab for editing, one for running commands).

:tabnew          " new tab
gt               " next tab
gT               " previous tab
:tabnext 2       " jump to tab 2

Workflow patterns

Multiple files: :e file1, :e file2, then :bn/:bp to switch. Or :split file2 to view side-by-side.

Exploring directory: :Explore or :Ex opens file browser (Netrw). Navigate and press Enter to open.

Search across files: :grep pattern searches files in project (requires ripgrep/grep installed). Then :copen to see results, :cn to next result.

:args *.py loads matching files into arg list, :argdo %s/old/new/g applies command to all.

:split file2         " view two files
:vsplit              " vertical split of current
:Explore             " file browser
:grep TODO *.py      " search for TODO
:copen               " show results

The more files you work with, the more valuable buffers/windows/tabs become. Start with :e for simple cases, graduate to splits for comparison, tabs for organizing distinct tasks.

wiki/neovim-buffers-windows-tabs.md · Last modified: by 127.0.0.1