Vim Window Splits and Tabs — :sp, :vsp, Ctrl+w Commands
Manage multiple files with Vim window splits, tabs, and buffers. Learn :sp, :vsp, Ctrl+w navigation, tab commands, and efficient multi-file workflows.
Buffers/Windows
Detailed Explanation
Window Splits
Command
Action
:sp {file}
Open file in horizontal split
:vsp {file}
Open file in vertical split
:sp
Split current buffer horizontally
:vsp
Split current buffer vertically
Ctrl+w s
Same as :sp
Ctrl+w v
Same as :vsp
Navigating Windows
Command
Action
Ctrl+w w
Cycle to the next window
Ctrl+w h
Move to window on the left
Ctrl+w j
Move to window below
Ctrl+w k
Move to window above
Ctrl+w l
Move to window on the right
Resizing Windows
Command
Action
Ctrl+w =
Make all windows equal size
Ctrl+w +
Increase height
Ctrl+w -
Decrease height
Ctrl+w >
Increase width
Ctrl+w <
Decrease width
Ctrl+w _
Maximize height
`Ctrl+w
`
Closing Windows
Command
Action
Ctrl+w q
Close current window
Ctrl+w o
Close all other windows (keep current only)
:only
Same as above
Tabs
Command
Action
:tabnew {file}
Open file in a new tab
gt
Go to next tab
gT
Go to previous tab
{n}gt
Go to tab number n
:tabclose
Close current tab
Buffers
Command
Action
:ls
List all buffers
:bn
Next buffer
:bp
Previous buffer
:bd
Close (delete) buffer
:b {name}
Switch to buffer by partial name
Use Case
You are working on a project with multiple files and need to view and edit them side by side using splits, manage them with buffers, or organize them with tabs.