Emacs ("Eight Megs And Counting Still") is a unix text editor you
can invoke by running 'emacs' (sometimes a more friendly version is
available under x-windows called 'xemacs'.) Here are some useful (or
essential!) emacs keys to know:
A key like M-x is typed by pressing ESC then x.
A key C-s is just control-s.
A key like C-x C-f is typed by holding down control
while you press x and f in sequence.
A key like C-x b is typed like control-x (release control) then b.
||Works on empty files to create a new file.
Use tab to complete filenames (ie, type hel and hit tab to
complete to hello.cc if there's a file called hello.cc)
||Saves the current buffer. C-x s (release control for the s)
will save all open buffers, prompting you for each one.
||Multiple undo is availible, by repeatedly pressing C-/.
||Prompts to save then closes emacs.
||From cursor to the end of the line. Puts the cut text in the clipboard,
which emacs perversely calls the "kill ring".
Pastes the most recent cut (or copy, etc.). If multiple lines were cut
in one operation, they are all pasted. You are not limited to pasting
the last cut/copy: After pasting use M-y to cycle through older
copied text in the "kill ring", pasting it instead.
||Start marking text
Starts marking text. After pressing C-space, move the cursor and
use commands like C-w or M-w to operate on that region.
In xemacs this will probably hilight the text; in regular emacs you might
not be able to see anything, depending on your terminal type.
Cuts the hilighted text into the "kill ring".
Copy the hilighted text into the "kill ring" (does not remove it).
Abort a command or operation. For instance, if emacs is prompting you
for a file to open, and you don't want to open a file, press C-g.
||Incremental search (forwards)
Allows you to search for text forwards or backwards from the
cursor. To see the next match, press C-s or C-r again.
|C-r||Incremental search (backwards)|
Press C-h a few times for an overwhelming but accurate help
system. Note that this is the same as the backspace key on some
||Maximize this window
Use these to remove and move the cursor between split-windows that
emacs will pop up (while in the help system, for instance).
||Maximize other window
||Move cursor to other window
||Switch to buffer
Switch between the various open buffers (by typing in the name of the file).
C-x C-b gets you a list of available buffers.
Emacs is most useful in cc-mode, which it will be in whenever you are
editing a file ending with .c or .cc. Under this mode, there are a
number of useful additional keys; you can see these by typing C-h
m. The most useful are probably C-c C-c (which comments out
the marked region) and tab, which properly indents the current
line. C-c C-q will automatically indent the whole function
under your cursor.
To facilitate debugging your programs, I recommend you add a goto-line
keybinding. Add the following to your .emacs in your home directory
(run emacs ~/.emacs to edit it):
(global-set-key "\M-g" 'goto-line)
This sets the key M-g (typed ESC-g) to the command
goto-line. (By default goto-line is not bound to anything. You can run
it by typing ESC-x goto-line (enter) line number (enter), but that
gets tedious quickly.) Now when g++ gives you an error like:
foo.c: In function `main':
foo.c:42: invalid lvalue in assignment
You can go ESC g42 (enter) to go to line 42 of your source file and
witness the error.
Other 15-211 Stuff