Emacs Commands

Emacs Commands
Emacs Commands

Emacs Commands:

emacs -nw
; Starts emacs without gui (terminal mode)

To show emacs commands and key bindings
C-h b - show help on key bindings (shortcuts)
C-x o - switch other window (in this case help)
C-x 1 - expand help window

Key Map
C = Control key (Ex: C-a = Control+a)
M = Meta/Alt key (can also be aped) (Ex: M-w = Alt+w)

C - Control is often used with basic units such as
    characters, lines, etc.
M - Meta key often operates on units of language,
    such as: words, sentences, paragraphs

point = location of cursor in text
mode line = status line

bksp = Backspace key
spc = Space key

*shift key* - May be needed for some command to work,
              such as: M-< and M->

C-x - Character extended command (followed by on character)
M-x - Named extended command (followed by a long name)

C-g - cancel partially inputted commands
C-g - cancels commands that are taking to long to execute

Numeric/prefix argument
C-u (0-9) command - repeats command
M-(0-9) command -  repeats command
C-u5 M-b - move back five words
C-u5 C-n - move down five lines
M-5 M-b - move back five words
M-5 C-n - move down five lines

Saving and exiting
C-x C-c - exit emacs
C-x C-s - save current file/buffer
C-x s - prompts to save each file in the buffer with unsaved changes

C-z - suspend emacs to background (shell command)
      fg or %emacs - bring emacs back to foreground (shell command)

Autosaved files
auto-saved-files - surrounded by ## (#filename#)
To recover file:
emacs filename ~x recover-this-file [prompts for confirmation] (recovers current file)
emacs ~x recover-file  filename (recover choosen file) (confirm)

Scrolling screen
C-v - view next screen (overlaps with two lines) [PgDn]
M-v - view previous screen [PgUp]
C-l - clear, redisplay text around cursor, middle of screen
       (continual toggles redraw top, bottom, middle)
C-u6 C-v - scroll screen down six lines
C-u6 M-v - scroll screen up six lines

Cursor movements
C-p - move up one line (previous)
C-n - move down one line (next)
C-f - move forward one character
C-b - move back one char
M-f - move forward after end of word
M-b - move to beginning of word
C-a - move to beginning of line
C-e - move to end of line
M-m - Move to the first non-whitespace character on the line
M-a - move to beginning of sentence
M-e - move to end of sentence
M-< - move to beginning of file
M-> - move to end of file
M-g g - Go to line (prompts)

Tab - Indent line
C-j - New line and indent, equivalent to "enter" followed by "tab"
M-\ - Delete all spaces and tabs around point. 

*killing* - is like cutting, it can be pasted [yanked]
bksp - delete char before cursor
C-d - delete char after cursor
M-bksp - delete word before cursor
C-d - delete word after cursor
C-spc - mark with space bar then cut with C-w, (M-w would copy)

C-a C-spc C-e C-w - move to start of line highlight till end and delete
C-a C-spc C-u3 C-n C-w - move to start of line highlight and delete 3 lines
C-spc M-> C-w - kill from cursor till end of file

C-w - Kill region (cut selected)
M-w - Copy region to kill ring [copy selected] (kill-ring-save)
M-d - Kill word
C-k - Kill from cursor to end of line (kill-line)
      C-k again to join with next line 
M-k - Kill to end of current sentence
      need 2 space between punctuation

C-a C-u4 C-k - kill 4 lines

C-y - yank back killed text (paste)
M-y - Cycle through kill ring after yanking (must hit C-y first)

C-y M-y M-y M-y - yanks 4 kills back
C-y C-u3 M-y - yanks 4 kills back

**keep in mind:
C-a C-spc C-e bksp - delete line with no way to yank back (could undo)
C-a C-spc C-e C-w - would kill/cut line and be able to yank/paste back

M-x replace-string - replaces all occurances after cursor

C-/ - Undo
C-_ - Undo
C-x u - Undo
**All three ways do same thing (different key strokes)**

C-s - search forward; C-s again for next match
C-r - seach backwards (reverse search)
C-g - also cancels a search

C-s someString C-x rt
; Alter text by column.
; Search sets a mark, then finds someString, create
; a rectangle, replace text to cursor.

C-x C-f - find a file (open a file)
          (return with no filename will list selectable
          directory structure)

M-/ - Hippie expand, cycles through possible expansions
      of the text before point

C-x 1 - close all other windows
C-x 0 - close current window
C-x C-b - list buffers
C-x b filename - switch to buffer by filename (tab completes)
C-x C-f filename - can also switch to buffer by finding file
*Messages* - this buffer contains messages that have been
             displayed on the status line
C-x s - prompts to save each file in the buffer with unsaved changes
C-x 2 - split window (vertically)
C-x 3 - split window (horizontally)
C-M-v - scrolls other window w/o cursor in it down (while split)
C-x o - switch cursor to other window
C-x oq - Close other window (help type windows)

**graphical emacs only**
M-x make-frame - create new frame
M-x delete-frame - delete frame

C-h t - built in tutorial
C-h b - show keybindings (shortcut keys)
C-h ? - help summary
M-x help - help summmary
F1 F1 - help summary
C-h k (keybinding) - Describes the function bound to the keybinding.
      Ex: C-h k C-f - show documentation for C-f command
C-h c C-f - display short help for C-f (in echo area, below mode line)
C-h f chosenfunctionName - display help of function by name
  Ex: C-h f previous-line - show help for function previous-line (C-p)
C-h v - help for variables
C-h a - list apropos (M-x relevant)
C-h a file - list all M-x commands with "file" in their name
C-h i - To choose manuals to read (info buffer)
       inside info buffer type: m emacs 
       to read emacs manual
C-h r - jump to emacs manual directly
C-h m - show documentation on your current major mode

Examples of major modes:
M-x text-mode - switch to text mode
M-x fundamental-mode - switch to fundamental mode

Examples of minor modes:
C-x auto-fill-mode - breaks lines by margin width at spaces
C-x f 20 - set margin width to 20 (used with auto-fill-mode)
C-u 70 C-x f - set margin width to 70 chars (default 70 usually)
M-q - in the middle of a paragraph, will refill previously typed
      text to current margin

 - exits recursive editing [(C-g only works for commands)]

M-x package-list-packages - list available packages
M-x package-install - install a package

M-x load-library RET gnus RET
Load gnus email/newsreader

M-x gnus-version
Show gnus version
Next Post »