Emacs n241.tplt Why learn an editor? As a web author, you should know something about UNIX and be able to work in the UNIX environment This mean learning an editor as much of your work will be in a text editor Three most popular are vi, pico and emacs Pico A little text editor packaged with pine You will outgrow quickly as it does not support keyboard macros, multiple files or quick HTML commands Vi Better than pico in a sense, however commands are a bit odd Has an edit mode and command mode Pressing a key gives a different response in the different modes Easy to forget which mode you are in Why Emacs? Has a number of features that make it will suited to web programming
-an html mode
-ability to look at directories from within the editor
More Features -ability to have multiple windows open at once
-running a command line shell without leaving the editor
-easy creation of keyboard macros
-online menus and powerful keystroke commands
-powerful programming language
Using the Menus Activated by using F10, if that doesn't work use Esc then ` (accent character, NOT the ' single quote/apostrophe) The menu will show you the keystroke sequence that is a lot faster to use than the menu Using Keystroke Sequences Emacs uses a control key to execute many commands Emacs is so powerful, and there are so many commands, that the control key with other keys will still not give you access to all the commands Keystroke Strategies Control commands
-the control key works as you would expect, is almost always held down as you press other keys
-holding the control key and then pressing the 'f' key moves one character to the left
-Emacs documentation shows as: C-f
Get me out of here!! C-g means 'cancel current command' If you are having strange things happen in Emacs, C-g is a good bet More Complex Control Commands The control key does not give you enough functionality on its own C-x s allows you to save a file (C=the Ctrl key, x= the x key, s = the s key) The C-x is a special command that says "housekeeping command coming" Most commands that deal with controlling Emacs itself begin with C-x The Meta Key 'Secondary' control key, 'alt' key on Windows, 'Apple' key on Macs This key can be used to run other Emacs commands The most common way to use the meta key, however, is the Esc key Not used exactly at the Ctrl key, press the Meta key (Esc or Alt), release then hit the next key
-example: M-f press Esc, release, press 'f' key
The M-x commands Every command in Emacs has a long, English-like name If you want to run a particular command, use M-x to run the command by its full name, you will receive a selection to choose from Online Help Best way to learn is by doing To use the online help
-enter Emacs and type C-h t This loads a text file from which you will learn to move the curser around, copy/paste text, save/load files, etc.
Online Help (continued) C-h calls the 'command-apropos' command which is an index in a more traditional help system
-it allows you to type in a word or phrase and returns a list of commands that contain that phrase
-scroll through the list to the command needed
Essential Commands
Key
Command
What it does
C-h
help-command
enters the online help
C-x C-s
save-buffer
saves file
C-x C-c
save-buffer-kill-emacs
Exit emacs
C-x u
advertised-undo
undo last edit(can repeat)
C-g
keyboard-quit
abort current command
C-x u
advertised-undo
undo last edit(can repeat)
C-f(right arrow)
forward-char
move forward one character
More Commands
Key
Command
What it does
C-b(left arrow)
backward-char
moves backward one character
C-p(up arrow)
previous-line
move up one line
C-n(down arrow)
next-line
move down one line
M-f
forward-word
move forward one word
M-b
backward-word
move backwards one word
C-v
scroll-up
move forward one screen
M-v
scroll-down
move backward one screen
References Emacs help UNIX in a Nutshell by Daniel Gilly, O'Reilly & Associates, Inc., 1992