Skip to content

dra1n/.emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Survival guide for the first week of emacs

When you start using emacs for the first time, your habits fight you every inch of the way. Your fingers long for the good old familiar keybindings. Here's an overview of the most commonly used shortcuts to get you through this pain:

  • C Shorthand for the ctrl-key
  • M Shorthand for the meta-key (bound to cmd on my mac settings)
  • S Shorthand for the shift-key

Files

  • C-x C-f Open a file. Starts in the current directory
  • C-x f Open a recently visited file
  • C-x o Open a file in the current project (based on .git ++)
  • C-x C-s Save this file
  • C-x C-w Save as ...
  • C-x C-j Jump to this files' current directory
  • C-x b Switch to another open file (buffer)
  • C-x C-b List all open files (buffers)

Cut copy and paste

  • C-space Start marking stuff. C-g to cancel.
  • C-w Cut (aka kill)
  • C-k Cut till end of line
  • M-w Copy
  • C-y Paste (aka yank)
  • M-y Cycle last paste through previous kills
  • C-x C-y Choose what to paste from previous kills
  • C-@ Mark stuff quickly. Press multiple times

General

  • C-g Quit out of whatever mess you've gotten yourself into
  • M-x Run a command by name
  • C-. Autocomplete
  • C-_ Undo
  • M-_ Redo
  • C-x u Show the undo-tree
  • C-x m Open magit. It's a magical git interface for emacs

Rectangles

  • C-x r k Kill the text of the region-rectangle, saving its contents as the “last killed rectangle” (kill-rectangle).
  • C-x r d Delete the text of the region-rectangle (delete-rectangle).
  • C-x r y Yank the last killed rectangle with its upper left corner at point (yank-rectangle).
  • C-x r o Insert blank space to fill the space of the region-rectangle (open-rectangle). This pushes the previous contents of the region-rectangle to the right.
  • C-x r N Insert line numbers along the left edge of the region-rectangle (rectangle-number-lines). This pushes the previous contents of the region-rectangle to the right.
  • C-x r c Clear the region-rectangle by replacing all of its contents with spaces (clear-rectangle).
  • M-x delete-whitespace-rectangle Delete whitespace in each of the lines on the specified rectangle, starting from the left edge column of the rectangle.
  • C-x r t string <RET> Replace rectangle contents with string on each line (string-rectangle).
  • M-x string-insert-rectangle <RET> string <RET> Insert string on each line of the rectangle.

Navigation

  • C-arrow Move past words/paragraphs
  • C-a Go to indentation, then start of line
  • C-e Go to end of line
  • M-g M-g Go to line number
  • C-x C-i Go to symbol
  • C-s Search forward. Press C-s again to go further.
  • C-r Search backward. Press C-r again to go further.

Emacs-nav

  • 1 Open file under cursor in 1st other window.
  • 2 Open file under cursor in 2nd other window.
  • c Copy file or directory under cursor.
  • d Delete file or directory under cursor (asks to confirm first).
  • e Edit current directory in dired.
  • f Recursively find files whose names or contents match some regexp.
  • g Recursively grep for some regexp.
  • j Jump to another directory.
  • m Move or rename file or directory.
  • n Make new directory.
  • p Pop directory stack to go back to the directory where you just were.
  • q Quit nav.
  • r Refresh.
  • s Start a shell in an emacs window in the current directory.
  • t Start a terminal in an emacs window in the current directory. This allows programs like vi and less to run. Exit with C-d C-d.
  • u Go up to parent directory.
  • ! Run shell command.
  • [ Rotate non-nav windows counter clockwise.
  • ] Rotate non-nav windows clockwise.

Window management

  • C-x 0 Close this window
  • C-x 1 Close other windows
  • C-x 2 Split window horizontally
  • C-x 3 Split window vertically
  • M-arrow Jump to window to the left/right/up/down

Help

  • F1 t Basic tutorial
  • F1 k Help for a keybinding
  • F1 r Emacs' extensive documentation