Emacs: The Software Engineer's ``Swiss Army Knife''
Overview
A D V E R T I S E M E N T
The emacs editor is arguably the ``editor of choice'' among many
software engineers. What is so nice about it? Here are some examples:
- Emacs has a really nice windowing capability, e.g. allowing you
to look at two different parts of a file at the same time.
- Emacs has its own programming language, emacs-lisp, which
you can use to customize emacs to your own personal usage patterns.
- Emacs has a lot of miscellaneous tools which are very helpful,
e.g. a built-in calculator.
As an example of the power of emacs-lisp, note that you can actually
use the vi editor from which emacs! That is because people have
written emacs-lisp programs to emulate vi, such as vi-mode.el,
viper-mode.el and vip-mode.el. (All emacs-lisp source code files have a
``.el'' suffix.) For some people, this gives ``the best of both worlds,''
combining the power of emacs with the parsimonious keystrokes of vi.
Notation
Most of the emacs commands use either the control key or the escape
key, which are denoted in emacs circles as C- and M-. For example, C-x b
would mean to type control-x and then b; C-x C-b would mean to type control-x
and then control-b; M-x would mean to type ESC then x (but release ESC before
typing x).
When in vip-mode, the emacs mode in which vi commands are
available, the ESC key can't be used for emacs commands, since it has
special meaning for vi. For this and other reasons, emacs provides
an alternate, the underscore key, i.e. `_'. So, for example, any M-x can be done
as _-x
Functions and Key Binding
To illustrate the concepts of functions and key bindings,
consider the action, common in any editor, of moving the cursor one character to
the left (e.g. this is done using the h key in vi). In emacs, the
formal name for this function is `backward-char'. As with the other emacs
functions, we could invoke this function using M-x, i.e. by typing
Of course, this would be far too much typing for such a small action.
Emacs allows key-binding to take care of this problem. In this case, for
example, we say that emacs has ``bound C-b to the function
backward-char,'' meaning that whenever we type C-b, that function will be
invoked.
We can change key bindings, and add new ones, by using various emacs
functions, e.g. `global-set-key'. In your file
(whose commands will be executed automatically each time you start up
emacs) for example, you could have a line
(global-set-key "\Cx-v" 'vip-mode)
which binds C-x v to the function `vip-mode'.
|