Experienced Programmers Introduction to Emacs
As an experienced programmer, I have used many editors, so when I encountered emacs I did not like the order of presentation of commands. Whenever I go to a new editor or return to an old editor I have not used for a while, I can easily start it on a particular file, and then suffer the embarassment of not being able to quit, exit without saving, as in the meantime I have messed the file up. So for instance I show you how to exit emacs but not how to start it which is emacs filename My next interest is how to copy text from place a to b. Followed by how to do this where a and b are in different files and how to deal with multiple files for other reasons. My aim has been to only present a bare minimum set to start working effectively with emacs. I am guilty of ignoring the impact of X-windows on the last 2 points. I give no instructions on how to move the cursor or how to enter text at a specific point or to delete characters until much later.
|C-<chr>||means hold the CONTROL key while typing the character <chr>|
|M-<chr>||means hold the META or EDIT or ALT key down while typing <chr>.|
If there is no META, EDIT or ALT key, then press and release the ESC key
and then type <chr>.
|C-x C-c||exits emacs cancelling all operations|
|C-g||sometimes required twice|
C-c I wanted C-x which is next to c then C-g removes it
|C-s||then enter text, do it slowly, watch how it works|
|C-s||finds next match of text entered above|
|C-Space||marks beginning or start of a region|
|move cursor||which now defines the end of a region|
|C-w||cuts or deletes the region||cut and paste|
|M-w||copies the region||copy and paste|
|move cursor||to where you want the text|
|C-y||pastes the text to its new home.|
Save C-x C-s to save file
Manipulate 2 files
The sequence of commands below should leave the commands always visible if you attempt them on this text. If not remember Cancel Commands and start again. This text was designed such that you should place this text within emacs and do the following commands, but that was when it was an ascci file and loaded to the web.
|C-x 2||you have 2 windows on the same file|
|C-x 0||kills this window, back to having only 1 window|
|C-x 2||2 windows again|
|C-x o||move to other window|
C-x C-f prompts you for file name
filename new or existing filename
enter some text to make it obvious this is the other file with only 2 files when emacs prompts you for which buffer you can usually accept the default. Note 0 number o is letter.
|C-x o||back to other window|
|C-x 1||kills other window, back to only one window|
Note The killing of a window does not effect the file or bufer (next subject) emacs file1 and C-x C-f and then entering file2 read file1 and file2 into buffers. If you got through the lot above then
|C-x 2||2 windows|
|C-x C-b||will show all buffers in the other window|
|in fact the C-x 2 is not nescessary|
|C-x o||to buffer window|
|C-x b||prompts you for which buffer|
|C-x 0||kill window and return to this window|
M-xreplace/string and follow emac prompts for search string and replacement string.
That is the end of the basic set. The following are a usefull miscellenous set of commands. Produce your own version of this document using emacs, that will show you what you need. Do not as I have done ignore X windows.
Now to a more conventional learning order
|C-a||move to beginning of line|
|C-e||move to end of line|
|M-<||move to the beginning of the file|
|M->||move to the end of the tutorial.|
|C-k||delete rest of line|
|<Delete>||delete the character just before the cursor|
|C-d||delete the next character after the cursor|
|M-<Delete>||kill the word immediately before the cursor|
|M-d||kill the next word after the cursor|
|C-k||kill from the cursor position to end of line|
|M-k||kill to the end of the current sentence|
Note that a single C-k kills the contents of the line, and a second
C-k kills the line itself, and make all the other lines move up.
|C-x u||undoes the changes made by one command.|
|C-z||returns to the shell but does not destroy the Emacs.|
in the early days I did this more by accident and it is important to know how to get back
fg %emacs command or with %emacs.
|M-x||auto-fill-mode will wrap text|
|C-M-v||scrolls text in the other window|
If you are using ESC for the META key, then you must type
ESC followed by CTRL-v