Friday, August 29, 2014

Emacs

open
emacs& RET     or click a graphical icon
emacs -nw RET     start in terminal, not in a windowing system
cancel
C-g     a command
M-g g    Go to line #

Text size
Shrink/Grow: C - - / C - + 

Copy & Paste

C-<space>
    Start selection
C-w
    Cut
M-w
    Copy
C-y
    Paste

12.1.2 Killing by Lines

C-k
Kill rest of line or one or more lines (kill-line).
C-S-backspace
Kill an entire line at once (kill-whole-line)

M-: evaluate function in minibuffer
(vi yy): C-a (beginning) C-spc (highlight) C-e (end) C-y (yank)

M-<Move to the top of the buffer (beginning-of-buffer). With numeric argument n, move to n/10 of the way from the top.
M->Move to the end of the buffer (end-of-buffer). 

15.10.4 Query Replace


M-% string <RET> newstring <RET>
Replace some occurrences of string with newstring
C-M-% regexp <RET> newstring <RET>
Replace some matches for regexp with newstring.

26.3.2 Indenting Several Lines

C-M-q
Reindent all the lines within one parenthetical grouping. 
C-u <TAB>
Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. 
M-x indent-code-rigidly
Shift all the lines in the region rigidly sideways, but do not alter lines that start inside comments and strings.
C-u 4 M-x indent-rigidly to indent the region by four spaces, C-u -4 M-x indent-rigidly to remove four spaces

Also, in Python mode, with a marked region, use C-c > and C-c <

Displaying in Another Window

C-x 4 is a prefix key for commands that select another window (splitting the window if there is only one) and select a buffer in that window. Different C-x 4commands have different ways of finding the buffer to select.

C-x 4 b bufname RET
Select buffer bufname in another window. This runs switch-to-buffer-other-window.
C-x 4 f filename RET
Visit file filename and select its buffer in another window. This runs find-file-other-window. See section Visiting Files.
C-x 4 d directory RET
Select a Dired buffer for directory directory in another window. This runs dired-other-window. See section Dired, the Directory Editor.
C-x 4 m
Start composing a mail message in another window. This runs mail-other-window, and its same-window version is C-x m (see section Sending Mail).
C-x 4 .
Find a tag in the current tag table in another window. This runs find-tag-other-window, the multiple-window variant of M-. (see section Tag Tables).

Deleting and Rearranging Windows


C-x 0
Get rid of the selected window (kill-window). That is a zero.
C-x 1
Get rid of all windows except the selected one (delete-other-windows).
C-x ^
Make the selected window taller, at the expense of the other(s) (enlarge-window).
C-x }
Widen the selected window (enlarge-window-horizontally).

No comments: