Basic emacs Commands

Command

Description

(Customize your emacs)

To enable the backspace key, disable tabs, and customize the indention, put the following statements in your .emacs file:

; disable the binding that has backspace call "help"      
; enable it do the same as delete
     (global-set-key [?\C-h] 'delete-backward-char)
     (global-set-key [?\C-x ?h] 'help-command) ;; overrides mark-whole-buffer
;disallow tabs
     (setq-default indent-tabs-mode nil)
;set indenting to 4 places instead of default 2
     (defun indentk ()
     (setq c-basic-offset 4))
     (add-hook 'c-mode-hook 'indentk)
 

emacs

The best way to get started with emacs is to do the tutorial. If you start emacs with no file name in the command line, you will get instructions on how to run the tutorial.

M-x help

Help (Note: M-x means to first hit the escape key and then hit x.)

C-x C-c

Quit emacs (Note: C-x means to press the control key and while you are holding it down, press x. Other places use the notation ^X or ctrl-X.)

C-x C-f

Find a file (i. e. open a file)

C-x C-s

Save a file (the one you see)

C-g

Get out of the command that you are in - try this when you don't know what is going on

C-x u

Undo (you can repeat this to undo several previous commands)

Arrow keys

You can use the arrow keys and also page up and page down to move the cursor.

C-d

Delete the character by the cursor

delete key (or backspace key)

Delete the character preceding the cursor

C-k

Delete from the cursor to the end of the line

Multiple Windows

With SSH, you can have any number of windows. I recommend that you start by opening one window in which you run a program and another window for editing. Edit a program in the edit window. Then save it--use C-x C-s--and then compile it and run it in the other window. Just click in a window to make it active. Note that you don't have to exit the editor--you have to save, but you can leave the editor there while you run the program. It is convenient to be able to see the program while you run it. It is also convenient to be able to start editing by just clicking in the edit window. Sometimes it helps to be able to see the execution output while you are editing. This is especially true if you compile and get a bunch of error messages--you can see the error messages while you edit the program to make the corrections.

C-v

Scroll-up: program itself moves "up" - will finally end up at bottom of screen

M-v

Scroll-down: program itself moves "down" - will finally end up at top of screen (Note: M is escape key)

C-s

It does an "incremental search", i. e. if you are looking for "hello", you type h and it looks for the first h. Then you type e and it looks for "he". etc.

C-space, C-@

Select text. You put the cursor at the beginning of the text and do C-Space or C-@ to mark that place, and then move the cursor to the other end of the desired region. (This is called the Mark Set" command.)

C-w

Copies and removes the text.  (The text is removed from the work buffer into the "Kill Ring" – the "Kill Region" command.)

C-y

Pastes (inserts) the text from the clipboard to where the cursor is. (This is called the "Yank" command.)

Notes by Dr. Wes Peterson and William Albritton