Next: , Previous: Important Keys, Up: Vi Commands

2.3 Buffers and Windows

In Emacs the text you edit is stored in a buffer. See GNU Emacs Manual, for details. There is always one current buffer, also called the selected buffer.

You can see the contents of buffers through windows created by Emacs. When you have multiple windows on the screen only one of them is selected. Each buffer has a unique name, and each window has a mode line which shows the name of the buffer associated with the window and other information about the status of the buffer. You can change the format of the mode line, but normally if you see ‘**’ at the beginning of a mode line it means that the buffer is modified. If you write out the content of the buffer to a file, then the buffer will become not modified. Also if you see ‘%%’ at the beginning of the mode line, it means that the file associated with the buffer is write protected.

We have the following commands related to windows and buffers.

C-n
Move cursor to the next-window (vip-next-window).
X 1
Delete other windows and make the selected window fill the screen
(delete-other-windows).
X 2
Split current window into two windows (split-window-vertically).
X 3
Show current buffer in two windows.
s buffer <RET>
Select or create a buffer named buffer (vip-switch-to-buffer).
S buffer <RET>
Similar but select a buffer named buffer in another window
(vip-switch-to-buffer-other-window).
K
Kill the current buffer if it is not modified or if it is not associated with a file
(vip-kill-buffer).
X B
List the existing buffers (list-buffers).

As buffer name completion is provided, you have only to type in initial substring of the buffer name which is sufficient to identify it among names of existing buffers. After that, if you hit <TAB> the rest of the buffer name will be supplied by the system, and you can confirm it by <RET>. The default buffer name to switch to will also be prompted, and you can select it by giving a simple <RET>. See GNU Emacs Manual for details of completion.