Vim buffer,tabs & windows
Buffers
buffer in Vim is an open instance of a file.
- Saved somewhere in Memory
- List all Buffers in current screen:
:ls
-
Open buffer:
:buffers
- The first column is the unique number identifying the buffer.
- The second is the set of attributes.
Buffer commands:
- Switch between buffers:
:bnext
- Open next buffer in list:
:bnext
&:bprevious
- Open all avalaible buffers:
:ball
- Execute operation on all open buffers:
:bufdo %s/search_tearm/replace_term/g | update
- Close buffer:
:bdelete
Useful commands:
- zz - Center the current line within the window
- zt - Bring the current line to the top of the window
- zb - Bring the current line to the bottom of the window
Windows
viewport onto a single buffer
Open new window:
:split { + filename}
->:sp
:vsplit { + filename}
->:vsp
Useful commands:
- :new [filename] - Open a new window above the current windowG
- :vnew [filename] - Open a new window beside the current window
- :split
- Edit the specified file in new window above the current window - :vsplit
- Edit the specified file in a new window beside the current window h,j,k,l - Navigate to the window in the given direction
Tab
collection of one or more windows(Group windows in useful way)
Useful commands:
- :tabnew - Open a new tab
- :tabedit
- Edit the file with the provided name in a new tab - gt - Go to next tab open
- gT - Go to previous tab
T - Break the current window out to a new tab