Editing Text with Emacs
Emacs is the Unix text editor of choice because it has extensions to
handle programming and text editing. Start emacs from an xterm
window by typing:
emacs filename &
Control keys are not essential in Emacs since all this can be
done from the menus, but if you log in remotely and run regular
emacs, you will need these handy control keys. M-x means push the
Meta key once, then the x key. Meta is the diamond on the
workstations, hold it down while pressing other keys.
To download a windows version, click
here, the Gnu Emacs
site, and choose the highest numbered version.
To run stat packages from within emacs, see ESS: Emacs Speaks Statistics
Commands
- Moving
- C-b
- move back one character M-b to move back one word
- C-f
- move forward one character M-f to move forward one word
- C-n
- move cursor down to next line
- C-p
- move up to previous line
- C-a
- move to beginning of line
- C-e
- move to end of line
- C-v
- move down one screen M-v to go up a screen
- Searching
- C-r
- reverse search
- C-s
- search forward
- M-%
- replace (with query)
- Remove and insert
- C-d
- delete one character under the cursor M-d to delete one word
- C-k
- (kill) remove from cursor position to end of line
- C-y
- yank back last kill to current cursor position
- M-y
- yanks back the previous kill, use only after C-y
- M-space
- marks cursor position
- C-w
- wipes out the region from current position to last mark
- M-w
- copies the region to the clipboard without wiping it
- Mouse-left
- marks a region
- Mouse-center
- inserts text
- Files:
- C-x C-f
- load file
- C-x C-s
- save file under current name
- C-x C-w
- save file under a new name
- Other
- C-h
- HELP (type A for apropos, then a word)
- C-u
- repeat command (takes a number, then another command)
- C-l
- recenter text with current line in center of window
- C-o
- open a new line
- C-z
- pause emacs (restart with jobs then % job#)
- C-x C-c
- exit emacs
For more help with Emacs, use the help button in the top right
corner, run the demo or look at www pages on the Xemacs homepage.
Modes
Emacs tries to figure out what kind of file you are editing
and tries to choose a mode which will make editing fit the file. Modes
we use a lot are HTML, TeX (or LateX) and [for running R or Splus]
ESS = Emacs Speaks Statistics, see
ESS description.
Data Entry
This page started as an intro to several stat packages. To run the
demos on those packages, you will need to type the following data into a
file and store it as 'tires.data'. (You may be able to copy it from
this window using the mouse, thus avoiding all typing.)
45 162 372 | 83 161 97 | 55 233 206 | 88 119 64
61 232 175 | 59 161 249 | 66 231 154 | 71 151 219
71 231 136 | 80 165 186 | 71 237 112 | 82 151 155
81 224 55 | 89 128 114 | 86 219 45 | 51 161 341
53 203 221 | 59 146 340 | 60 189 166 | 65 148 283
64 210 164 | 74 144 267 | 68 210 113 | 81 134 215
79 196 82 | 86 127 148 | 81 180 32 | 56 200 228
68 173 196 | 75 188 128 |
Hold down the left mouse button and drag across the text, then move to
your emacs window, click middle mouse button, and it should pop into the
emacs window. To use the data, you need to make it into 3 columns,
removing the vertical separators. Good practice for the keystrokes
listed above. Go to the right of the 372 in line 1, use C-k to kill to
end of line, press return, then C-y for yank. Just leave the separators
for now, move over 3 columns and repeat until line 1 becomes:
45 162 372
| 83 161 97
| 55 233 206
| 88 119 64
Do the same for the other lines, then go back to the top of the file and
use M-% to replace all | characters with nothing, or space. Save with
C-x C-w (give it a name) or C-x C-s if it's already named, and you are done.
Information about
Unix.
More
info about emacs.
Stat package demos:
Author: Jim Robison-Cox
Last Updated: Wednesday, 09-Jan-2008 14:40:36 MST