Scientific Supercomputing at the NIH

Emacs

emacs is a powerful fullscreen editor with many capabilities. If the $DISPLAY variable is set, emacs will come up as an X client by default. Otherwise, emacs will run as a screen editor.

To edit a file, type:

[user@helix ~]$ emacs filename

A good way to get familiar with emacs is to type Ctrl-T, which will take you through a tutorial. Your arrow keys will enable you to move around the file. Most emacs commands are entered using the 'Ctrl' or 'Meta' keys. To use the command, hold down the Control (or Meta) key and hit the appropriate key. On most keyboards the 'Meta' key is the escape key.

A summary of emacs commands is below for your convenience:

Command What it does
Ctrl-h ? Brief help menu
Ctrl-h t Substantial tutorial
Ctrl-z Suspend emacs process (fg to resume)
Ctrl-x Ctrl-c Normal exit
Ctrl-x Save current buffer
Ctrl-s Save current buffer (1 or more buffers)
Ctrl-v View next screen
Meta-v View previous screen
Ctrl-l Repaint screen, scroll/recenter at cursor
Ctrl-f Advance one char
Meta-f Advance one word
Ctrl-b Back up one char
Meta-b Back up one word
Ctrl-n Vertical advance
Ctrl-p Vertical backup
Ctrl-a Start of current line
Meta-a Start of current sentence
Ctrl-e End of current line
Meta-e End of current sentence
Meta-< Top of file
Meta-> bottom of file
Ctrl-u n Repeat next command n times
Ctrl-g Give up on current command
Ctrl-x u Undo last command
Ctrl-x 1 Leave only one window (chosen by cursor)
Ctrl-x o Move cursor to other window
Meta-Ctrl-v Scroll other window to its next screen
Ctrl-o Open new line after the cursor
Del Erase previous character
Ctrl-d Delete current character
Meta-d kill rest of word
Ctrl-k Kill rest of line
Meta-k Kill rest of sentence
Ctrl-u 0 Ctrl-K Kill to line start
Ctrl-u 1 Meta-K Kill to sentence start
Ctrl-y Yank last kill to present location (paste type 1)
Meta-y Replaced yanked text by kill ring entry
Ctrl-x Ctrl-f Find new file for editing
Ctrl-x Ctrl-b List buffers
Ctrl-x b Change buffersMeta-x top-level<CR>Escape to top editing level
Meta-x auto-fill-mode<CR> Toggle text autofill on/off
Meta-q Re-fill text in current paragraph
Ctrl-s Search forward incrementally
Ctrl-r Search backward incrementally
Meta-Ctrl-s Search forward incrementally for regular expression (see next p.)
Ctrl-@ Set mark to current location (point)
Ctrl-x Ctrl-u Change region to upper case
Ctrl-x Ctrl-l Change region to lower case
Ctrl-w Kill region (cut)
Meta-x copy-to-buffer<CR> Save region to buffer
Ctrl-x x Copy region into register
Ctrl-x g Glue register contents into current location (paste type 2)
Meta-q Re-fill region as text
Ctrl-x . Set fill prefix to string left of point
Meta-Ctrl-\ Indent region
Meta-x print-region<CR> Get hard copy of region
Ctrl-x, Ctrl-q Toggle read-only mode (alt: Meta-x toggle-read-only)
Meta-x replace-string<CR> Global replace (will prompt for strings)
Meta-% Interactive replace:
space = yes
del = no
esc = stop
! = from now on
^ = backup one instance
Ctrl-t Transpose two characters
Meta-t Transpose two words
Ctrl-x Ctrl-t Transpose two lines
Meta--, Meta-u Change last word to upper case
Meta--, Meta-l Change last word to lower case
Meta--, Meta-c Capitalize first letter only of last word
Meta-$ Check spelling of word
Meta-x ispell-buffer<CR> Check spelling in whole buffer
Ctrl-x ( Start keyboard macro definition
Ctrl-x ) End kb macro definition
Ctrl-x e Execute most recent kb macro
Ctrl-x d Start directory editor
d Mark entry for subsequent deletion
u Unmark entry for subsequent deletion
x Delete marked entries
n Move to next entry
p Move to previous entry
o View current entry
Ctrl-x o Switch cursor to other window
q Quit directory editor