Help:Emacs

From CECS wiki
Jump to navigation Jump to search

Emacs is a highly customizable general purpose editor with many add-on modules to provide language and format specific functionality. Emacs can serve as a complete environment for development (IDE).

Vendor homepage
Free Software Foundation
Software homepage
http://www.gnu.org/software/emacs/
Software availability
unix and windows (windows version not installed here)
command to type to run
emacs
View online documentation
  • Internal tutorial (C-h t) is good for beginners.
  • Info documentation (C-h i) is fairly complete
  • Short docs: key bindings (C-h b), mode specific (C-h m), M-x apropos
  • Modules are written in elisp, which is frequently well commented (read the source)
Location of example files
  • Ask if you need example configuration files
  • elisp source is in /opt/emacs-21.3/share/emacs and /opt/GNUemacs/share/emacs
  • Try M-x customize to automatically bulid a config file to your preferences
Other unix editors
vi, dtpad, pico

Quick start tutorial[edit]

Emacs has internal documentation which is very complete and is better than any synopsis I could write. Here are a few brief things to get you started anyway:

To start emacs from a graphical login, type:

 emacs & 

To start it in a non-graphical environment, just type

  emacs
  • In emacs documentation, the notation C-h t means hold the control key and press h and release control and press t.
  • The notation M-x means hold the meta key and press x. For some keyboards, the Alt key is used as the meta key. If you can't find the meta key, press and release the Esc key instead.

A few of ssd's favorite emacs keys are:

C-h t starts the emacs tutorial (Strongly recommended!)
C-h b gives keybindings for the current mode
C-h m give help on the current major mode
C-h C-h help on help
C-h i info -- the emacs documentation browser
C-x f find (open) a file for editing
M-x allows you to type a function name to run (instead of pressing the key you can't remember that does the same thing)
C-x o (little letter o) switch to other subwindow (when you have multiple subwindows)
C-x 1 (one) make the current subwindow the only one
C-x 2 split the fcurrent window into two windows
C-g abort operation (when you get stuck in the bottom line)
C-S-_ (ctrl-shift-underscore) undo (emacs has infinite undo!)
C-x C-c quit and save everything

Arrows work too, but touch typists prefer these:

C-n move to the next line
C-p move to the previous line
C-b move back one character
C-f move forward one character
C-v move forward a page
M-v move backwards a page

Emacs allows editing of multiple files in multiple windows without restriction. Within emacs documentation the following terms are used to talk about this:

file
a file on disk
buffer
a buffer might hold a copy of a file in memory (but there might not be an associated file, or it may be a version transformed for easy editing)
window
a mapping of a buffer onto a portion of a screen (multiple windows might show different views of the same buffer)
frame
a rectangular section of the screen split into multiple windows (a frame is what you probably think of as a window)


Emacs has a large number of specialized modes. Many are automatically selected depending on the type of file you open. Some are extremely specialized. Here are a few of ssd's favorite special modes:

C-x C-b buffer menu mode shows what buffers you have open
C-x b switch buffer switch to a different named buffer in the current window
C-x o next window switch to the next window
C-x 1 one window make the current window the only window in this frame
C-x d dired mode a file manager mode -- manipulate your files with emacs
M-x picture-mode picture mode mode useful for making ascii pictures and column editing

The following keys make emacs as powerful as many integrated development environments available in Windows:

M-x make make mode runs make in a subwindow to capture errors from a compile
M-x ` next error (back tick) find the location in your source code that caused the error
M-x gdb debug mode run the symbolic debugger on your program within emacs (will follow in your source code as the program runs)

You can get documentation on all of these from info (see above) or by looking through the mode's key bindings (see above).