Emacs Commands

The newly learned ones:

  • C-x i: insert file
  • C-x C-v: Find alternative file
  • C-x C-w: Save as copy
  • C-h: Enter help
  • C-h k: Help about keystroke
  • C-h f: Help about function

Use goto-line command to go to a specific line.

  • C-_: Undo (same as C-x u)
  • M-d: Delete a word on the cursor (handy!)

Everything you delete with C-k, C-w and copy with M-w will go into the kind ring. C-u with Del or C-d will go into the kill ring as well. But the sole single chatacter deletion will not go into the kill ring.

  • C-space: activate the mark region
  • C-x C-x: Verify the selected region
  • C-w: Delete the currently marked region;
  • M-h: Mark a paragraph
  • C-x h: Mark the entire buffer
  • M-w: kill-ring-save, which could be used in copying text.
  • M-y: delete the most recent text in kill ring and get the next ones
  • M-c: Capitalize the first character
  • M-l: Put a word in lowercase
  • M-u: Put a word in uppercase
  • M-x ov: Toggle overwrite mode
  • M-x revert-buffer: Undo all changes made since last saving
  • C-r: Backward searching
  • C-s C-w: Search the word
  • C-s C-y: Search the text till the end of line
  • C-s Enter: Non-incremental search
  • M-%: Query replace
  • The variable case-fold-search determines whether searches are case-sensitive.
  • The variable case-replace determines whether to replace according to the old capitalization pattern.
  • C-M-s: Regex Incremental search
  • C-M-%: Regex query replace

NOTE: Spell checking a text needs installation of ispell or flyspell, so the related chapters in Learning GNU Emacs are ignored here

  • M-/: Complete the word with nearest word with that as prefix (Can search cyclically when used repeatly)
  • Command abbrev-mode: abbreviation mode
    • C-x a i g: for add-inverse-global
    • C-x a i l: for add-inverse-local
  • edit-abbrevs
  • list-abbrevs
  • kill-all-abbrevs: Stop use of all abbreviations
  • C-x b: switching between buffers
  • C-x C-b: show buffer list
  • C-x ->: Cycle through the buffers
  • C-x k: Delete a buffer
  • kill-some-buffers can do the above in a batch way
  • C-x 4 f: to open a file in a new window
  • C-x 4 b: to open a buffr in a new window
  • C-M-v: to scroll the other window
  • C-x o: move from one window to another
  • C-x 0: delete the window you are in
  • C-x s: Save all buffers
  • C-x C-q: Make any buffer read-only
  • C-x ^: Make the current window taller
  • C-x }: Make the current window wider
  • C-x {: Make the current window narrower
  • C-x r m: Place a bookmark at the cursor position
  • C-x r b: Jump to a bookmark
  • C-x r l: List all bookmarks

Under dired:

  • n, p etc.: move between lines
  • v: preview file
  • C-x d: Start Dired
  • A: Do a regular search on marked files, M- to find next match
  • B: Byte-compile file
  • C: Copy file
  • d: flag for deletion
  • D: Delete instantly
  • e: Edit file
  • f: Find
  • g: Refresh
  • i: Insert a listing of subdirectory to the current dired buffer
  • L: Load file
  • m: Mark
  • M: chmod
  • o: Find file in another window and move there
  • C-o: Find file but don't move
  • Q: Query replace string in marked files
  • R: rename file
  • s: Sort the display by date or by filename
  • v: View file in read-only mode
  • w: copy the filename into kill ring
  • Z: compress
  • .: Flag numbered backups for deletion
  • !: Do shell commmand on current or marked files
  • +: create a directory
  • ^: move up to parent directory

compile goes to compilation mode

  • C-x `: move to next error and its position
  • M-n: Move to next error message
  • M-p: Move to next previous message
  • C-c C-c: Visit source for current error message
  • M-;: Indent for comment
  • C-M-\: Indent each line in the region
  • M-m: Back to the first non-blank character on the line
  • visit-tags-table: Connect the TAGS file generated by etags to Emacs
  • M-: find tag
  • list-faces-display: List all code font

C, C++ support

  • M-a: move to the beginning of current statement
  • C-M-a: Moveto the beginning of surrouding function
  • C-M-h: Mark the entire function
  • C-c C-u: Move to the beginning of current preprocessor conditional
  • c-set-style: Set C language style ˘