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-lineswill toggle how long lines are displayed
Put cursor where it is supposed to go, begin recording (
C-x (), do
thingy, isearch to next location, and then stop recording. (
This lets you see what is going to be edited next, and hit
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
C-x r N
Inserts numbered lines in the rectangle. Accepts a prefix argument to change at what number the lines start at.
Prompts for a string and inserts it at the current rectangle. So you can go from this:
one two three four
- one - two - three - four
by setting the mark on the
one, then moving to the
four, then running the command.
C-x n n
Only displays the region. Good for focusing. Use
C-x n wto
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.
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-uproceeds 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
Join this line to the previous and fix up whitespace at
join. Useful if
auto-fill-modewas turned on and you need to
unwrap a line.
In dired, opens the file the cursor is on in the other window.