RET     type the "RETURN" key.
TAB     type the "TAB" key.
SPC     type the "space bar".
DEL     type the "BACK SPACE" or "DELETE" key.
ESC     type the "ESCAPE" key.
C-h     hold the "CONTROL" key down while typing "h".
M-h     hold the "META" key down while typing "h".
M-C-h   hold the "META" and "CONTROL" keys down while typing "h".
ESC-a   type the "ESCAPE" key followed by "a".

Note: on terminal with both ESC and M, they are the same in Emacs.

Emacs Setup

Starting, loading and quiting

To start emacs, type :

> emacs filename &

You can load several documents into the same emacs-session and it is therefore no need to start several emacs-sessions (this will occupy unnecessary resources). To load or create a new file use C-x C-f and type path/filename. To quit Emacs use C-x C-c.

When you have started your emacs-session, it will look something like this.


When Emacs is started, it normally loads a Lisp program from the file ".emacs" in your home directory. We call this file your "init file" because it specifies how to initialize Emacs for you.

"Window configuration"

A map description of the various regions in the emacs-window:

line and column numbers

Add to this .emacs :

;; Display column and line numbers (from
;; anonymous@archive.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive)
(require `column)

time and/or date

Add this to .emacs :

;; Display the time on the status line
(setq display-time-24hr-format t)       ; 0 <= hh <= 23

Basic operations


Moving around is done by using the cursor-keys. Normally the keyboard should be setup so that "Home", "End", "Page Up", "Page Down", "Insert", "Delete" will work as expected, ie. go to top of document, end of document, move up one page, move down one page, inser text at current cursor position, delete text at current cursor position, respectively.

Reading, writing, saving and inserting files/buffers


C-x C-f         find-file: read file FILENAME
C-x C-s         save-buffer: save current buffer in it's file
C-x s           save-some-buffers: save some modified "file-visiting"
C-x C-w         write-file: write current buffer into file FILENAME
C-x C-i         insert-file: insert FILENAME at cursor position

Recovery from problems


C-g             Quit. Cancel running or partially typed command.
C-]             Abort innermost recursive editing level and cancel
                the command which invoked it ("abort-recursive-edit").
M-x top-level   Abort all recursive editing levels that are currently
C-x u           Cancel a previously made change in the buffer contents
                ("undo"); can be repeated up to a number of times
                fixed by the variables "undo-limit" and



C-x C-b                 List all buffers.
C-x b BUFFER RET        Select or create a buffer named BUFFER
C-x k BUFNAME RET       Kill buffer BUFNAME

Cursor motion in text


C-f     move Forward a character
C-b     move Backward a character
M-f     move Forward a word
M-b     move Backward a word
C-n     move to Next line
C-p     move to Previous line
C-a     move to beginning of line
C-e     move to End of line
M-a     move back to beginning of sentence
M-e     move forward to End of sentence
M-{     move backward to the beginning of the paragraph
M-}     move forward to the end of the paragraph
M-<     go to beginning of file
M->     go to end of file

Marking text


C-SPC           set the mark at the current point location.
C-x C-x         interchange point and mark; allows to show where the
                mark is.

Deleting text


DEL     delete the character just before the cursor.
C-d     delete the next character after the cursor.
M-DEL   kill the word immediately before the cursor.
M-d     kill the next word after the cursor.
C-k     kill from the cursor position to end of line.
M-k     kill to the end of the current sentence.

Insert and undo


C-y     insert back the last killed section of text.
M-y     after C-y, insert the previously killed section of text, this
        can be repeated.
C-x u   undo character deletion (actually any change made).

File transfer (FTP)

You can use Emacs to transfer files between two machines. This is really just an interface within Emacs which uses ftp as you would from the command line. Emacs, however, provides easy access to commands from menues and files bye highlighting and marking for transfer/viewing. To login to a remote host from Emacs, type C-x C-f to usually opens a file for editing. Remove path and type :

/myusername@remotehost.uio.no: mypassword

and Emacs will display the files in the directory of the host. To enter a directory press middle mouse button, to mark a file point/click and type "m". To unmark a file point/click a file and type "u". As usual you can get the mode command menu (in this case ftp-menu) by pressing Ctrl-(right-button).

GNU Emacs Reference Card

The GNU emacs reference card gives a list of the basic emacs commands.

Getting in and out

  • Start emacs: emacs or emacs file
  • Visit/find a file: ^X^V or ^X^F
  • Insert another file: ^X i
  • Write a file: ^X^W
  • Save a file: ^X^S
  • Suspend emacs: ^Z
  • Exit emacs: ^X^C

Moving around

  • forward 1 character: ^F
  • back 1 character: ^B
  • forward 1 word: ESC F
  • back 1 word: ESC B
  • previous line: ^P
  • next line: ^N
  • beginning of line: ^A
  • end of line: ^E
  • beginning of sentence: ESC A
  • end of sentence: ESC E
  • forward 1 screen: ^V
  • back one screen: ESC V
  • beginning of document: ESC <
  • end of document: ESC >


  • Search (incrementally, forward): ^S
  • Reverse-search (back): ^R
  • to stop searching: ESC


  • Delete previous char.: Delete-key
  • Delete next char.: ^-D
  • Delete previous word: ESC Delete-key
  • Delete next word: ESC D
  • Kill to end of line: ^K
  • Kill to end of sent.: ESC K
  • Transpose 2 chars.: ^T
  • Transpose 2 words: ESC T
  • Set mark: ^-spacebar or: ^-@
  • Exchange point & mark: ^X^X
  • Kill region (cut): ^W
  • Copy region (copy): ESC W
  • Yank (paste): ^Y
  • Capitalize word: ESC C
  • Uppercase word: ESC U
  • Lowercase word: ESC L


  • Enter foo mode: ESC x foo
  • Set fill column: ^X f
  • Fill paragraph: ESC Q
  • Fill region: ESC G


  • Make two windows: ^X 2
  • Make one window: ^X 1
  • Go to other window: ^X o

Fixing problems

  • Abort current command: ^G
  • Undo last big change: ESC x undo
  • Redraw screen: ^L


Many functions in emacs can be called by typing

ESC X function

-- where function can be anything from search-and-replace: ESC X replace-string [return] or: ESC X query-replace [return] to file inclusion:: ESC X insert-file [return]


  • Get help: ^H
  • Get help: info program: ^H i
  • Get help: tutorial: ^H t
Published July 4, 2011 9:38 AM