Emacs Mini Tutorial
I've seen the huddled masses escaping through VI, pondering the latest
vagaries of ce and just trying to quit out of ed. Being one of those
in the light, I thought it was time I brought forth some information on
that most holy editor,EMACS! NO, do NOT
run in fear, it is not so bad
as you've heard! NOTE: There are ports of Xemacs
to almost every possible platform, including Windows95, NT, Linux and
other Unix's.
Looks like someone created a more complete
Emacs Beginner's Tutorial here.
If you are just getting started (and wish to use my settings), here is
what you do:
-
Install xemacs, for instance: yum install xemacs
-
Download dot.xemacs.gz, gunzip it, and rename it to:
$HOME/.xemacs
-
Download elisp.tgz, move it to your $HOME directory,
gunzip it, and un-tar it. It should create a $HOME/elisp directory.
-
Now edit the .xemacs/init.el file. Search for 'greear' and replace it (and anything
else near it) with values corresponding to your setup. I hope this will be
fairly straightfoward. If you have problems, let me know and I'll try to
make it more clear.
You should now be ready to run xemacs. Try viewing your ~/.xemacs/init.el file, or
any other text file or source code you have laying around.
Why you should not Fear Emacs
Emacs is possibly the most powerful editor around. That said, it is almost
certainly the most complicated! The complication is in the setup however:
once you get your .xemacs/init.el file set up, the battle is almost won. I
offer several sample .xemacs (including the one I use every day.) towards
the end. All you'll need to do is copy one to your home directory.
Key Combinations
The next great complaint you hear from people (mostly vi users of all people)
is "How am I ever supposed to remember all those key combinations!!??" This
is most certainly a valid question. Or wrather, was a valid question
back in the days of vt100 screens. Today, xemacs is fully X aware
and with the drop down menus and accelerator keys programmed into the
.xemacs file, there is almost no need for arcane key combinations,
even though they still work of course.
Quick list of Key combinations
NOTE: ctrl-x means hold ctrl down and press x, if something follows, then
press it after you have pressed the first two. For example: ctrl-x 1 means
press ctrl, press x, release both, press 1. Commas seperate equivalent
combinations. For example: ctrl-x s, F7 means that the F7 key does the
same thing as ctrl-x s.
- ctrl-x s, F7 Save current file.
- ctrl-x f, F3 Load (new) file.
- Meta-x compile Then enter compile cmd, press enter. After you enter
this info one time, just click on the Compile button on the left hand
side.
- ctrl-s Search foward
- ctrl-r Search backward
- ctrl-g Cancel current command.
- ctrl-k Cut from cursor to end of line.
- ctrl-y, F6 Paste (yank) the last cut line(s).
- meta-y
Yank previous cut, cycle through all past cuts (keep entering it.)
- ctrl-shift-underline, F2
Undo, can do multiple undo's. Just keep pressing the combo.
- ctrl-x-2 Divide current frame into 2 sub-frames.
- ctrl-x-1 Consolidate sub-frame(s) into one frame.
- ctrl-kp_enter Go from .C to .h file, or visa-versa.
- ctrl-kp_plus Go foward in files buffer.
- ctrl-kp_minus Go backward in files buffer.
- ctrl-l Redraw, especially useful in HTML mode.
Benefits of Emacs: Color coding of source code.
Now, everyone is already comfortable with SOME editor, so why should
they change to emacs? First and foremost, it is designed for programmers.
Almost every kind of source code imaginable will be color coded. Of special
interest may be the java and c/c++ color schemes. It also colorizes HTML
code, although not quite as well java or c++.
Benefits of Emacs: Integrated Compilation.
If you compile from within emacs, you get the added benefit of being able
to click on the offending error in the compile-output window. You will then
be taken to that line in your source code. Much more can be done along this
line, but leave that for more advanced documentation.
Quick list of Nice Features and Hints.
- To Compile Meta-x, enter compile, enter command to compile. After
that you need only click on the compile button on the left hand side.
- Auto Source Indention When editing source code, just hit
TAB to automatically indent your code, either foward or backward.
- If it seems to hang, press F7 The auto-saver tries to hard and
sometimes temporarily hangs emacs. I should try to fix this, but haven't
gotten around to it yet.
- Use Multiple Frames Try using the File -> New Frame option. Also
try Ctrl-x-2 (Ctrl-x-1 un-splits your frame.)
- Name Completion: When opening files, use TAB for name
completion.
- Opening Files from Dir. Listing Use the middle mouse button to
open files when listed in a directory listing.
Screen Captures of Various Modes
Java Mode
C++ Mode
HTML Mode
Ben Greear
Last modified: Fri Jul 2 15:34:02 PDT 2021