Emacs

Emacs is the text editor we recommend you use. It is very flexible and powerful. For an introduction to Emacs, try this page (you may not be able to use g++ from within your Emacs, however).

to start Emacs, type emacs at the system prompt. To leave Emacs, type C-x C-c from within Emacs.

Below is a list of commonly used commands in Emacs. In all the following, M means the meta-key (the diamond-key or sometimes the Esc key) and C means the Control key. M- or C- means hold down the meta or control key and hit the key(s) following the -.

  • C-x C-c - quit Emacs.
  • C-x C-f - open a file in Emacs.
  • C-x C-s - save a file.
  • C-x C-w - save a file under a different name.
  • C-g - abandon a command that you've goofed up.
  • C-s - search forward for a specific string.
  • C-r - search backward for a specific string.
  • C-M-s - do a regual expression search.
  • C-v - scroll to the next scrren.
  • M-v - scroll to the previous screen.
  • M-% - query replace a string or regular expression (it'll query at each occurrence; hit the space bar to replace, the delete key to skip to the next one without replacing, or the Esc key to exit the query-replace).
  • C-x 1 - delete all other windows.
  • C-x 2 - split this window in two vertically.
  • C-x b - switch to another window.
  • M-q - fill the current paragraph.
  • M-< - go to the start of the buffer.
  • M-> - go to the end of the buffer.

Emacs supports tab completion, so for instance if you have a long file name starting with li, you can do C-x C-f li and then hit the tab key and it should finish the file name for you.

You may also be interested in etags, which helps you find all occurences of a function name in different files.

Emacs has excellent documentation and help facilities, including help on how to customize your Emacs. To get into the Emacs info files, from within an Emacs buffer type:

  • M-h i to enter info
  • m Emacs to get info on Emacs
  • m Concept Index to get info on concepts
  • m program editing to get info on programs
  • m Tags to get info on tags
From there, other commands will let you move around.
  • p to go to the previous topic
  • u to go up one level
  • n to go to the next topic
  • m NAME to go to the topic NAME if NAME is on the menu for this topic.
The menus are clearly marked in the info.