This is a collection of Emacs shortcuts that I've collected over the past year. I'll likely update it as I go on.


  • toggle-truncate-lines will toggle how long lines are displayed

Macro wisdom

Put cursor where it is supposed to go, begin recording (C-x (), do
thingy, isearch to next location, and then stop recording. (C-x ))
This lets you see what is going to be edited next, and hit C-s C-s
if you want to skip to the next match.


To select text in a rectangle, use C-x SPC. The region will then highlight like a rectangle. The kill and yank commands will work like normal (i.e. hitting
C-k will kill the rectangle.)

  • C-x r M-w
    Copy rectangle as kill. (Think M-w)

  • C-x r N
    Inserts numbered lines in the rectangle. Accepts a prefix argument to change at what number the lines start at.

  • M-x string-insert-rectangle
    Prompts for a string and inserts it at the current rectangle. So you can go from this:


    to this:

     - one
     - two
     - three
     - four

    by setting the mark on the o of one, then moving to the f in four, then running the command.

Misc. Keystrokes

  • C-x n n
    Only displays the region. Good for focusing. Use C-x n w to
    display everything.

  • C-x $
    To hide lines in the current buffer, type ‘C-x $’
    (‘set-selective-display’) with a numeric argument N. Then lines with at least N columns of indentation disappear from the screen.

  • C-u
    Prefix argument. The default is 4. If you want to grow the current
    window by, say, 15 lines, do following: C-u 15 C-x ^.

  • C-x C-k C-i
    Inserts the current value of the keyboard macro counter and
    increments it. When C-u proceeds the command, the previous value
    is inserted, and the counter is not updated. A prefix argument
    specifies a different increment.

  • C-x C-k n
    Give the last kbd macro a name, which you can then call

  • ESC-^
    Join this line to the previous and fix up whitespace at
    join. Useful if auto-fill-mode was turned on and you need to
    unwrap a line.


  • C-o
    In dired, opens the file the cursor is on in the other window.