emacs
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.
C-x C-f |
Open File |
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)
|
C-x C-s |
Save File |
Saves the current buffer. C-x s (release control for the s)
will save all open buffers, prompting you for each one.
|
C-/ |
Undo |
Multiple undo is availible, by repeatedly pressing C-/.
|
C-x C-c |
Exit |
Prompts to save then closes emacs.
|
C-k |
Cut line |
From cursor to the end of the line. Puts the cut text in the clipboard,
which emacs perversely calls the "kill ring".
|
C-y |
Paste |
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.
|
C-space |
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.
|
C-w |
Cut text |
Cuts the hilighted text into the "kill ring".
|
M-w |
Copy text |
Copy the hilighted text into the "kill ring" (does not remove it).
|
C-g |
Quit command |
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.
|
C-s |
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) |
C-h |
Help |
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
unenlightened terminals.
|
C-x 1 |
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).
|
C-x 0 |
Maximize other window |
C-x o |
Move cursor to other window |
C-x b |
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.
|
C-v |
Pagedown | |
M-v |
Pageup | |
|
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.
Carnage Melon
Other 15-211 Stuff
|