Vim
Buffers
A buffer directly matches an open file in memory (i.e. the content of a tab in a standard IDE).
The big difference is that when you close a tab in a standard IDE you close the file as well. Not in Vim, if you close a window containing a buffer, the buffer is still there, hidden.
A buffer can be in one of three states:
- active - displayed in a window
- hidden - not displayed, but it exists and the file is still open
- inactive - not displayed and is empty
:buffers
of :ls
lists all of the buffers
To navigate through the buffer list:
:buffer {id or name}
:bnext
or:bn
:bprev
or:bp
:bfirst
or:bf
:blast
or:bl
Buffers are created automatically if you create a window. You can also used
:badd {filename}
.
:bdelete {id or name}
, :m,n bdelete
, %bdelete
are all ways
to delete buffers.
Windows
A window in vim is nothing more than a space you can use to display the content of a buffer. Don't forget - when you close the window the buffer stays open.
To create windows you can use the :new
command or:
CTRL+W s
split current window horizontallyCTRL+W v
split current window verticallyCTRL+W n
slit current wino horizontally and edit a new file
To move cursor from one window to another you can use CTRL+W j,k,h,l
To move windows:
CTRL+W r
rotate the windowsCTRL+W x
exchange with the next window
Resizing windows:
CTRL+W =
equal sizeCTRL+W -
decrease heightCTRL+W +
increase heightCTRL+W >
decrease widthCTRL+W <
increase width
Tabs
A buffer is an open file, a window is the container for an active buffer. A tab is a container for a bunch of windows. It is a very different concept to that of a tab in a standard IDE.
:tabnew
or tabe
new tab
:tabclose
or :tabc
close tab
:tabonly
or :tabo
close every other tab
gt
go to next tab
gT
go to previous tab