Basic Emacs Commands

Command Description
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.
emacs filename This will create and edit a file with the emacs editor. For example, this will create a C program: emacs program.c
Arrow keys You can use the arrow keys and also page up and page down to move the cursor.
C-x C-s Save the file. C-x means to press the control (Ctrl) key and while you are holding it down, press x. Other notations use ^X or Ctrl-X.
C-x C-c Quit emacs and save the file.
(or Delete key)
Delete the character at the cursor.
Backspace key Delete the character preceding the cursor.
C-k Delete from the cursor to the end of the line.
C-s It does an “incremental search”. For example, if you are looking for “hello”, you type h and it looks for the first h. Then you type e and i t looks for “he”. etc. Type C-s again, and it will look for the next occurrence of the word.
C-v Not to be confused with “paste”, this scolls down in the file. Useful for longer programs.
M-v This scolls up in the file. The M stands for the Meta key, which is the Esc key on most keyboards.
C-x u This will undo the previous command.
Customize your Emacs To enable the backspace key, disable tabs, and set the indention to 2 spaces, 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
;set indenting to 2 places
     (defun indentk ()
     (setq c-basic-offset 2))
     (add-hook 'c-mode-hook 'indentk)
;display column numbers 
     (setq column-number-mode t)