Emacs Useful Bits

Updated . Posted . Visible to the public.

Indent

M-i indents current line, combined with multiple cursor - indents regions

Git

C-x v g Blame https://www.gnu.org/software/emacs/manual/html_node/emacs/Old-Revisions.html Show archive.org snapshot , use a to go back in history for current line

Nav

M-- M-d delete word backwards

C-x 4 c clone-indirect-buffer-other-window

Folding

M-1 C-x $ collapse everything indented

C-x $ show all

Search and replace

toggle-case-fold-search to replace without case gimmicks
M-x find-name-dired RET glob RET t Q to replace in multiple files

(find-name-dired gets its name from running find . -name 'PATTERN' )

Bookmarks

C-x r b Jump to the bookmark
C-x r m Set the bookmark

New Goodies

C-x TAB adjusts the text indentation in the region

eww internet browser

ruby-align-to-stmt-keywords

M-s h . highlights the symbol found near point without prompting

M-s . starts a symbol (identifier) incremental search forward with the symbol found near point

(replace-pairs-region (point-min) (point-max) '(["from1" "to1"] ["from2" "to2"]))

Narrowing

C-x n d Narrows to current function
C-x n n Narrows to region
C-x n w Cancels narrowing

Isearch

M-s o Call occur with the current search term.

M-r Toggle between regular-expression searching and literal-string searching.

C-M-% Start a regular-expression query replace using the current search string.

Elisp

M-: Read a single Emacs Lisp expression in the minibuffer, evaluate it, and print the value in the echo area (eval-expression).

C-x C-e Evaluate the Emacs Lisp expression before point, and print the value in the echo area (eval-last-sexp).

Ctrl+x r w Call window-configuration-to-register (then give it a letter or digit as name).

Ctrl+x r j Call jump-to-register to restore a previously saved configuration.

Macro

F3 Start defining a keyboard macro (kmacro-start-macro-or-insert-counter).

F4 If a keyboard macro is being defined, end the definition; otherwise, execute the most recent keyboard macro (kmacro-end-or-call-macro).

Shell

C-c C-o Delete the last batch of output from a shell command (comint-delete-output).

C-c C-s Write the last batch of output from a shell command to a file (comint-write-output). With a prefix argument, the file is appended to instead. Any prompt at the end of the output is not written.

C-c C-r or C-M-l Scroll to display the beginning of the last batch of output at the top of the window; also move the cursor there (comint-show-output).

Regexp

M-x re-builder Test regexp interactively on current buffer. C-c C-q to exit.

C-u C-x = Display the category of the character under the cursor.

Use \s- for whitespace character class. To capture use escaped parens, e.g. \(.*\)

Highlight current line

M-x hl-line-mode

Multiple cursors

M-x mc/edit-lines (with region selected)

Fill paragraph

M-q Fill current paragraph (fill-paragraph).

C-x f Set the fill column (set-fill-column).

Dired

C-u s Change ls switches on the fly.

Showing whitespace

M-x whitespace-mode Shows whitespace caracters.

Customize colors/fonts etc.

C-u C-x = will print the face found at the current point

Ev Dolzhenko
Last edit
Ev Dolzhenko
Posted by Ev Dolzhenko to Ev's deck (2013-11-04 17:43)