Search:
  University Web Sites
  Camden Web Sites

  Computing
  Services:

  About Us
  FAQs
  Office of Information
    Technology (OIT)

  Lab Reservations
  Smart Classrooms

  Jump to:
  Camden Campus
  Camden Web Mail
  myRutgers Portal
  RU Libraries
  RU Main

  Questions
  Comments

Camden Computing Services
  SupportStudentsFaculty and Staff_

Gnu emacs

Computing Services Information Document - Sun/Unix



C- ; Means press the control key and then, as you are holding it down, type the character shown to the right of "C-"
ESC; Means press and release the escape key, then type the character shown to the right of "ESC". The EMACS tutorial writes this as M- or META.
<cr>; Means type the RETURN (Carrage Return) key
<del>; Means type the DELETE or BACKSPACE key.

START EMACS
emacs filename ; Starts up emacs. Whenever you save a file, a backup copy is automatically kept (file.BAK).
emacs +n filename ; Starts up emacs and moves cursor to line n.
(ALWAYS start up emacs WITH a filename....otherwise it will prompt you for a filename. If you don't give it a filename, it will start up a scratch buffer that is not automatically saved.)

READING AND WRITING FILES
C-x, C-v ; Visit File (Read in a file to edit)
C-x, C-s; Save file (under default filename)
C-x , C-w ; Write file (using name you specify)
C-x, 4, f , Find file in other window (for use with 2 windows)

EXITING
C-x, C-c; Exit EMACS. If you have not saved all the buffers you have changed, it will ask if you are sure you wish to exit. (Warning - if you enter emacs without specifying a filename, this command will exit emacs without saving anything).

ABORT COMMAND
C-g; Abort currently executing command (to get out of unknown places).
C-x, u; Undo previous Change.

DISPLAY CONTROL
C-l, Clear Screen and Redisplay (use to clear messages from display).
C-v, Scroll to Next Screen
ESC v Scroll to Previous Screen
C-x, C-g; GOTO line number n. (Will ask for line number.)
C-x, C-k; What Line. Will state current line number where cursor is.

CURSOR CONTROL
C-b ; Backward Character
C-f ; Forward Character
C-a ; Beginning of Line
C-e ; End of Line
C-p ; Previous Line
C-n ; Next Line
ESC <; Beginning of Buffer
ESC >; End of Buffer
(or use ARROW keys to move cursor around the screen)

TEXT HANDLING
<del> ; Delete Previous Character
C-d; Delete Present Character
C-y Restore (yank) Most Recent Deletion (that was done with either a C-k or a C-w ).
C-t; Transpose Two Characters
C-k; Kill Line Forward
C-@; Set Mark
C-w; Kill Region

HINT: an effective way to move whole regions of text is to set a mark, C-@ , at the top of the region you wish to move, then move the cursor down to the bottom of the region and then kill the region, C-w . Then move the cursor to the place where you want this region moved to, and restore (yank) the region back in, C-y .

SEARCHING
C-s; Forward Search
C-r ; Reverse Search
Note: To end a search, type ESC or move with C-f, C-b, C-n, C-p, etc.
HINT: The last string you have searched for is always remembered, just try typing C-s (or C-r) an extra time.

REPLACING STRINGS
ESC x; replace-string <cr> Prompts for "old-string" and "new-string". Replaces all occurrences of the "old-string" with "new-string", from the current cursor position to the end of the buffer. Note you actually have to type in "replace-string".
ESC % ; Like replace-string, but checks before replacing string, i.e. (waits for subcomand)
During ESC %, (query-replace), the following sub commands are used:
<space bar> or y (accept change)
. (change current and quit)
<del> or n (no, don't change)
ESC or C-g or q (quit, no more changes)

COMMANDS FOR DEALING WITH 2 WINDOWS
C-x, 1; Delete all other windows but current one
C-x, 2; Split current window (lets you make a window)
C-x , O ; (alphabetic "O" not number zero) Move to other window
C-x, ^ ; ( ^, the upcaret character) Enlarge window one line
C-x , 0; (number zero, not alphabetic "O") Remove current window
C-x, 4, f ; Find file in other window

HINT: you can use two windows to copy lines from one program to another. Put each program into a window, then KILL the line(s) from one, switch windows, and YANK them back in the right place. To put a different file in a second window, use C-x 4 f, "find file in other window".

HINT: You can open up two windows, place the source code in one window and compile in the other. To compile, enter "ESC-x compile" and then enter "cc filename" or "f77 filename" or "pc filename". You can also open up two windows, place the source code in one window and debug in the other. To debug, enter "ESC-x gdb" and then enter the executable file that needs to be debugged.

COMPILING
ESC-x, compile; It will ask you the to specify the compilation command. Useful with two windows (Source code in one window and compile in the other).
C-x `; Finds Errors. Go to next error in source code window. Used after compilation in 2 window mode.

HELP with EMACS
Esc ?; Starts the help command. Follow this with one of the below:
c; followed by a command keystroke; Shows the command name.
k ; followed by a command keystroke; Describes the command.
?, Lists the help subcommands
C-h; Lists and describes the help subcommands
t ; Start the EMACS tutorial! >>> Recommended for learning EMACS!!!

Spell Checking
ESC-x ispell-buffer ; Type this command in, to activate the ispell spell checker on your entire file.

HTML & SGML Support
Emacs supports pull down menus of commands to insert tags and text formatting.
C-c C-c n; Name Anchor
C-c C-c h; Href Anchor
C-c C-c i; Image
C-c RET; Paragraph
C-c C-j; Line Break
C-c C-c -; Horizontal Rule
C-c C-c o; Ordered List
C-c C-c u; Unordered List
C-c C-c c; Check Boxes
C-c C-c l; List Item
C-c 1; Heading 1
C-c 2; Heading 2
C-c 3; Heading 3
C-c C-v; View Buffer Contents
C-c C-s; Toggle Autoviewing
C-c C-t; Insert Tag
C-c C-a; Insert Atributes
C-c C-b; Backward Tag
C-c C-f; Forward Tag
C-c DEL; Delete Tag
C-c ?; Describe Tag
C-c TAB; Toggle Tag Visibility
C-c 8; Toggle 8 bit Inssertion



Questions/comments regarding Camden Computing Services or this web site
can be directed to: help@camden.rutgers.edu.
Last updated: January 10, 2006, 11:26 EST.

© 2005-2008 Rutgers, The State University of New Jersey. All rights reserved.