If you change your mind about deleting a buffer before typing x, you can unmark the buffer by going to the appropriate line and typing u. As a convenience, the Delkey also unmarks the previous buffer in the list. Why would you do this? Simple: dautomatically moves you down one line. If you mark a file for deletion and immediately change your mind, you can press a single Delrather than moving to the previous line and typing ufor unmark ).
To save a buffer, go to the line for the buffer you want to save and press s. The letter S
appears in the first column. Press xwhen you really want to save the buffer. Therefore, you can look at the buffer list, choose which buffers you want to delete and which you want to save, and then type xto do everything at once. Again, you can press uor Delto cancel saves if you change your mind.
One command that affects a buffer immediately when you type it is tilde ( ~). Typing ~marks a buffer as unmodified. In effect, this symbol tells Emacs not to save changes automatically (since the buffer is unmodified, Emacs has no reason to save changes with its auto-save feature). Of course, if you have made changes, the changes are still in the buffer; it's just that you're in essence "lying" to Emacs to say that no changes have been made. Also, if you change the buffer again after marking it unmodified, Emacs once again knows it has been modified and saves it automatically in a backup file. The backup filename (not coincidentally) has the format filename~ .
You can change a buffer's status from read-write to read-only and back again by pressing %. Pressing %changes the buffer's status immediately. Percentage signs appear on the mode line when a buffer is read-only. When you are editing, you can toggle a buffer between read-write and read-only by pressing C-x C-q, as we discussed earlier.
You can also use the buffer list to display multiple buffers in windows. To display one of the buffers in a full screen, move the cursor into the buffer list's window; use C-nand C-pto move to the line for the buffer that you want, and press 1(the number one). Emacs displays the buffer in a full-screen window.
If you want to display one of the buffers in place of the buffer list, you can press f. To put a buffer in another window (i.e., one not occupied by the buffer list), type o. Emacs displays the buffer in the other window and puts the cursor there. Pressing C-ohas a slightly different result; Emacs displays the buffer in another window but doesn't put the cursor there.
One final buffer display command remains. You can ask Emacs to display multiple buffers and have Emacs create windows for them dynamically. To select buffers to be displayed in windows, press m(for mark ) next to the buffers you want. Emacs displays a >next to the buffers you mark with m. To tell Emacs to display the buffers you've marked, press v. Emacs makes horizontal windows to display the buffers you've chosen.
To get rid of the *Buffer List*
window, type C-x 0if you are in the buffer list window or C-x 1(the number one) if you are in another window. Table 4-2shows a summary of buffer manipulation commands.
Table 4-2. Buffer manipulation commands
Keystrokes |
Command name |
Action |
C-x b Buffers → Select Named Buffer |
switch-to-buffer |
Move to the buffer specified. |
C-x→ Buffers → Next Buffer |
next-buffer |
Move to the next buffer in the buffer list. |
C-x Buffers → Previous Buffer |
previous-buffer |
Move to the previous buffer in the buffer list. |
C-x C-b Buffers → List All Buffers |
list-buffers |
Display the buffer list. |
C-x k |
kill-buffer |
Delete the buffer specified. |
(none) |
kill-some-buffers |
Ask about deleting each buffer. |
(none) |
rename-buffer |
Change the buffer's name to the name specified. |
C-x s |
save-some-buffers |
Ask whether you want to save each modified buffer. |
Table 4-3summarizes the commands for working with the buffer list.
Table 4-3. Buffer list commands
Keystrokes |
Action |
Occurs |
C-n, Space, n, or |
Move to the next buffer in the list (i.e., down one line). |
Immediately |
C-p, p, or |
Move to the previous buffer in the list (i.e., up one line). |
Immediately |
d |
Mark buffer for deletion. |
When you press x |
k |
Mark buffer for deletion. |
When you press x |
s |
Save buffer. |
When you press x |
u |
Unmark buffer. |
Immediately |
x |
Execute other one-letter commands on all marked buffers. |
Immediately |
Del |
Unmark the previous buffer in the list; if there is no mark, move up one line. |
Immediately |
~ |
Mark buffer as unmodified. |
Immediately |
% |
Toggle read-only status of buffer. |
Immediately |
1 |
Display buffer in a full screen. |
Immediately |
2 |
Display this buffer and the next one in horizontal windows. |
Immediately |
f |
Replace buffer list with this buffer. |
Immediately |
o |
Replace other window with this buffer. |
Immediately |
m |
Mark buffers to be displayed in windows. |
When you press v |
v |
Display buffers marked with m; Emacs makes as many windows as needed. |
Immediately |
q |
Quit buffer list. |
Immediately |
Depending on your requirements, you may want to work with side-by-side windows in addition to or instead of horizontal windows. For finer control, you may want to know how to size windows (and because they're not GUI windows, you can't do that with the mouse). [23]You may also want to know how to compare files between windows, a good feature for basic file comparison.
4.6.1 Creating Vertical or Side-by-Side Windows
To split the window vertically into two side-by-side windows, type C-x 3. You can execute this step repeatedly to create more side-by-side windows.
Type: C-x 3

Читать дальше