[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Emacs is a colossus: It is a plain text editor looking back on a long history, with a version number in the twentieth, a confusing abundance of functions and a stone age internal programming language called Emacs LISP. There are some expansions of the abbreviation "Emacs", e.g., Eight Megs And Constantly Swapping, or Escape-Meta-Alt-Control-Shift, making fun of its memory appetite or hotkey combinations.
The complexity of Emacs may deter the novice. But once you made your first steps and learned your first control sequences, you will realize how big the benefit of using Emacs is and how excellent support you can get by its various plug-ins. These packages make Emacs into a highly efficient tool for Java programming, LaTeX type setting or HTML editing.
Break the barrier now! Dare to dive into Emacs!
This short tutorial is meant to guide you in your first steps and give you all the knowledge to beat Notepad users in speed and safety.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Emacs exists in different layouts, we use xemacs. Just start it from the shell, optionally supply a file name. E.g.,
$ xemacs assignments/prop.tut & |
You are probably used to the reappearing menu pattern from GUIs: File, Edit, View, Help. Emacs has a structure that looks similar in the beginning, but turns out to be badly organized--flooding you with a lot of irrelevant functions, but hiding the most basic editing commands like cut & paste from you. In Emacs you better not use the menus, but learn the control key sequences instead. This actually is to your benefit: You will find it much faster after some time.
The Emacs community has a special tradition how to name the key modifiers Control and Alternate:
Here is a list of the basic file commands:
Most interactive commands like "find file" or "write file" prompt for input in the so-called mini buffer, the last line of the emacs window. The minibuffer supports edit commands like cut & paste and, what is very comfortable, the file name completion known from Unix shells: Just press the tab key to complete a filename, and space to get a list of possible completions, from which you can select one with the mouse. Navigating through your file structure with the keyboard and completion is much faster than double-clicking through file dialogs. The minibuffer also facilitates a history: repeated up brings back the last inputs. Minibuffer commands:
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Cursor movement and basic editing is almost identical to Windows editors. Here is a list of useful deleting commands:
Essential for editing is cut & paste. All deleting commands that delete more than one character are indeed cut-commands. They accumulate the killed characters in the cut buffer until you move the cursor with other commands. If you start cutting more text then, the cut buffer will be emptied before accumulating the new characters. Another way to cut is to mark text and killing the selection, region in Emacs terminology. Here are the keys for cut & paste:
Usually you will cut text by a sequence of C-k commands or by C-space, marking a region and C-w and then paste it back with C-y.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Find and replace always start at the cursor position. If you want to move to the next occurence in a search, just hit C-s again.
After entering text and replacement you are prompted at each occurrence whether to replace or not. You have the options yes, no, ! to replace all and C-g to abort. (Abort and undo work in all contexts.)
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Many Emacs plug-ins (modes in Emacs terminology) provide special indentation modules for the supported programming language. You invoke these modules by:
If you do not have a special Emacs mode for you file syntax, you have to indent manually. To indent a region, mark it and indent it with C-x tab. The region then becomes inactive, but you can reactivate it with M-C-z and indent it for one more column. A better way is to supply an argument to the indentation command and indent the region as far as you want in one step. You can provide arguments to commands by C-u <arg>. Examples:
A good default indentation is provided in the "indented text mode". You can switch to it by invoking the command `indented-text-mode', which has no key sequence binding. Commands without a key sequence bound to them are launched by M-x <command>. Completion with tab also works for commands, therefore type:
M-x indented tab |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Emacs is designed for convenient editing of several files at a time. It has a clean philosophy of "multi editing", by distinguishing buffers, frames and windows.
Here is some commands to change the buffer displayed in the current window:
You will find that you often need M-C-l. An alternative to C-x b is C-x C-f, since the latter does not load the file again if it already occupies one buffer. Window and frame commands:
All these commands do not affect the buffers. Deleting a window does not kill the buffer.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This is where the big potential of Emacs is present, and here it gets complicated. We focus on some very basic issues.
An Emacs mode is a plug-in written in Emacs LISP that controls the behaviour of the buffer it is attached to. Usually it provides indentation, syntax highlighting and hotkeys for compiling and jumping to error locations. Sophisticated modes turn Emacs into a full-fledged IDE (integrated development environment). Emacs decides on base of the file extension which editing mode is loaded.
Useful modes for editing Tutch files are the indented text, line and column number mode. They can be used in parallel and are invoked by
M-x indented-text-mode return M-x line-number-mode return M-x column-number-mode return |
The indented text mode is one of the major modes, which are exclusive. The other two are minor modes which can be used as add-ons onto any major mode. Keys for the indented text mode are:
You can configure Emacs to load these modes automatically when loading `.tut'-files. Personal customization of Emacs is put into the file `~/.emacs'. Here are the necessary lines to add:
(command-execute 'line-number-mode) (command-execute 'column-number-mode) (setq auto-mode-alist (append '(("\\.tut$" . indented-text-mode) ("\\.req$" . indented-text-mode)) auto-mode-alist)) |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here is a random list of some useful commands:
Here are more deleting commands:
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |