Some Useful Emacs Commands

^ stands for Ctrl or Control - Usually found in the lower left of the keyboard
M stands for Meta (Escape key) - Usually found in the upper left corner

Note that the Meta (Esc) is always pressed prior (i.e. sequentially) to the following key. Avoid holding down the escape key. Note also that ^x^f is different from ^xf. In the second case, do not hold down the control key while pressing f.

The most important commands listed below are in bold. 99% of your emacs experience will deal with these commands and therefore we have made a quick reference guide which you may find handy to print out and keep on hand.

Moving around

  • ^p previous line
  • ^n next line
  • ^a beginning of line
  • ^e end of line
  • ^f and ^b forward and back one letter at a time
  • arrow keys also move the cursor around (duplicating ^p, ^n, ^f, and ^b)
  • Mv previous screenfull
  • ^v next screenfull
  • M< top of document
  • M> end of document
  • Cutting and Pasting

  • ^k kills (cuts) to the end of the line (a second ^k will cut the carriage return)
  • ^y yanks back text from the last kill (several kills in a row count as one kill unless another command or some typing somes between them)
  • My immediately after a ^y will replace what you just yanked by previously killed text (and will keep moving backward through previous text you've killed)
  • ^d deletes the character at the cursor location
  • ^2 some text ^w wipes out a region (see below for regions) These can be yanked back with ^y
  • using the mouse to copy and paste will work under Xwindows (such as elm)
  • Files

  • ^x^f find file
  • ^x^s save file
  • ^xi insert file at cursor position
  • ^xs save any files that have changed (you'll have to answer y/n for each file)
  • ^x^w write out current buffer into new file (to save under a different file name)
  • Search and Replace

  • ^s search starting at cursor point (you'll be prompted for search string) Repeated ^s commands will find the next occurance.
  • ^r reverse search
  • M (Escape) or any other command or mouse click will terminate a search
  • ^s^s will use the previous search string
  • M% prompts for a string and replacement and will ask for confirmation before replacing
  • Mxreplace-string prompts for string and replacement and replaces all without confirmation
  • Miscellaneous commands

  • ^g abort command in progress
  • ^x^c quit emacs (^z will suspend)
  • ^xu undo, will continue to undo until the last save
  • M$ check spelling of this word
  • ^xb change buffers (switch between files if more than one are open)
  • Mq formats paragraph so all lines are no longer than "fill" amount
  • ^xf sets "fill" amount to current cursor position
  • use space or tab for word or command completion on the command line (minibuffer)
  • You can create a region by setting a mark at one end with ^2 and moving the cursor to the other end. Operations on regions include ^w (wipe out), ^x^i (indent, if no region is set, indents current line) and ^g (formats region according to "fill" amount).

  • Back to Technical Assistance Main Menu
    © Gary Thompson 1996
    Questions, comments, suggestions and ideas may be sent to garyt@soc.duke.edu