17.E: Mode | 17: Emacs | 17.C: Cutting and Pasting |
When you tell emacs to edit a file, it copies your file into a region of central memory which it calls a buffer. (Just to be safe, it also makes a backup disk file with a name like filename~). Each file has it's own separate buffer, and emacs allows you to edit multiple buffers (files) simultaneously.
To start editing a file, you issue the find file command C-x C-f filename. If the file doesn't exist, emacs will create a new one for you with the name you use for filename. Try creating a new buffer by finding your home page:
C-x C-f public-html/index.html
If you are editing more than one buffer, it is useful to know the names of all buffers currently in memory. This is obtained with the C-x C-b command. After you enter this command, a list of buffers will appear on a split screen. You can move your mouse to either of the windows.
You can switch to any of the listed buffers by just clicking on it with your mouse and then pressing the number 1. If you don't have a mouse, use C-x o to switch to the buffer window, and then use the arrow keys.
Try switching among your buffers now using C-x C-b.
To get rid of the buffer list, type C-x 1 in the other window or C-x k in the window with the list. The first command only hides the buffer list by making emacs display only one window (this will be covered further in the "Windows" section) . The C-x k command actually kills the active window.
Be warned. When you edit a file, emacs does not automatically save the file. To move the edited file from the buffer to the disk (save it), you issue the commands
C-x C-s | save current file |
C-w filename | write current file (buffer) to filename |
C-x k | kill current buffer with no write |
We have now covered the basic emacs commands. In the next few sections we'll deal with some more specialized commands. Let's start with mode line.
17.E: Mode | 17: Emacs | 17.C: Cutting and Pasting |