If I ever make a book out of this, an interesting idea would be a flowchart format. I could make use of an otherwise useless paradigm by saying, 'If you want to do X, follow this route, and this route for Y' in a diagram at the beginning of the chapter, or wherever else I need it. Some modes, such as Outline, exist both in major and minor form. A contextual menu can be invoked in X using C-Right Mouse The main menu is accessible in text mode via F10 or M-`. One can then navigate options by typing their representative letters, C-p/C-n, or Page Up C-x/M-x: commonly used commands -- C-x often work on fundamental units that do not vary among modes; M-x frequently deal with language units C-x yada: slightly less common commands (file manipulation in particular) Stands for character eXtend; M-x of course executes functions C-c yada: modal bindings C-x 4: other window C-x 5: other frame C-x 6: two column mode M-o: face menu C-x v: version control shit C-x : MULE keybindings Prefix followed by C-h displays all keybindings that begin with that prefix. Emacs evidently cooperates with DnD C-x C-v: if you fuck up the file name C-x i: insert file M-<, >: beginning, end of file C-x C-f, brethren, take default directory from current buffer C-x C-w: 'Save As' C-x 4 C-f: visit file in other window C-x 4 b: switch to buffer in other window C-x b can be used to create new buffers, although they will not automatically be saved on exit Ctrl-Left Button: buffer menu M-x kill-some-buffers: counterpart to C-x s M-x delete-windows: genocide windows viewing a given buffer Substantial jumps seem to set the mark; M-<, M-> do for a fact C-l: clear screen, redraw, and center display -- numeric arguments specifies lines from top or bottom depending on negativitude C-u C-v performs a function *similar* to C-u 0 C-l Point: current position in text, in between character at Cursor and preceding character C-u: numeric argument to command, sometimes, but not always used as a repeat count (C-u 8 C-v) One can even use a numeric argument for self-insert-command M-number performs a similar function, although there is one substantial difference: C-u with no argument does it four times. Moreover, stacked C-u works in powers of four (e.g., C-u C-u C-u == 64) Scrollbar in X: Button 1: Scroll buffer down one page Button 2: Set position or scroll (dragging) Button 3: Scroll up one page C-x 1: Single window dominates frame M-: Acts like ^W in Vi Insert Mode M-k: kill to the end of the sentence M-hyphen C-k: delete whole line, but not newline!! C-x : delete sentence backwards C-: set Mark M-h: mark paragraph C-x h: mark whole buffer C-x C-p: mark page (as per page-delimiter) C-w: kill text in between Mark and Point M-w: copy text in between Mark and Point; try me on a read-only buffer! C-x C-x: exchange Mark and Point C-y: yank from Kill Ring; M-y replaces it with earlier selections in the kill ring; try giving M-y arguments, positive or negative. Eventually M-y will go from Kali to Satya (hence 'Kill Ring') C-y will also yank from clipboard, bitch Other clipboard related commands: M-x clipboard-kill-region M-x clipboard-yank M-x clipboard-kill-ring-save The variable kill-ring-max dictates the number of kills kept. M-x set-variable can be used to set its value C-k with numerical argument will kill that many lines and their newline characters; C-k will also append consecutive kills to the same position in the Kill Ring C-x u: undoes changes -- self-inserted characters are usually dealt with in groups of 20; C-_ or C-/ perform the same function C-x s: :wa M-x recover-file: #self-explanatory# C-h ?: meta help C-h c: describe key briefly C-h k: describe key verbosely C-h f: describe function C-h v: describe variable C-h a: command apropos M-x apropos-variable M-x apropos-doc (very powerful) C-h i: Info C-h m: describe mode C-x f with numeric argument sets text width in Auto Fill mode; M-q reformats paragraph C-M-v: scroll other window ESC ESC ESC: bust out of anything, including recursive edits M-{. }: move paragraphs C-x [, ]: move through page delimiters (defined by variable page-delimiter) C-q: insert raw characters M-x goto-line: self-explanatory M-x revert-buffer: self-explanatory auto-save-interval: controls frequency of autosaves default-major-mode: self-explanatory C-s C-w: like g* in Vi C-s C-y: search using cursor until end of whole line C-s M-y: search with text from Kill Ring C-s C-s: repeat previous search C-s : non-incremental search C-s C-w: word search (like * in Vi) M-x replace-string: self-explanatory M-%: query-replace Ctrl-]: abort the command that launched the current recursive edit C-M-c: escape innermost recursive edit M-x eval-expression: prompted for sex-p in Minibuffer (or M-:) C-x z: repeat last command C-ESC ESC: repeat last complex evaluation, with opportunity to edit. M-p and M-n may be used to traverse history (as with anything else in the Minibuffer) case-fold-search: ignore case in searching and matching when set to t, given that the query is uniformly lowercase case-replace: automagically change case of replacements setq-default: buffers with no overriding value of their own will inherit the value instantiated by setq-default C-M-s ENTER: regexp search C-M-r ENTER: regexp search backwards C-M-s: regexp isearch C-M-r: regexp isearch backwards C-M-%: query-replace regexp M-x replace-regexp (USE WITH CARE) M-x ispell-buffer, ispell-region (among others) ispell-command-name sets name of executable M-$: spell word under cursor M-Tab: complete word from dictionary (this does not use ispell/aspell, what-have-you; it uses ispell-complete-word-dict) ispell-alternate-dictionary: dictionary for spelling help, whose value is also the default for ispell-complete-word-dict. ispell-alternate-dictionary also serves a few other miscellaneous functions. (It is used, for instance, by M-x lookup-words.) Emacs will use `look' instead of `grep' if it can. For this to work, textual dictionaries specified to ispell must be sorted according to same options given to look by ispell-look-options. (For example: sort -df big-dict) M-x flyspell-mode or M-x flyspell-prog-mode for restriction to comments and strings (Microshit Weird dynamic spellchecking) (setq-default flyspell-mode t) Middle click will display menu of possible replacements Flyspell can also be used for buffers and the current region as you might have already guessed. It will also create word abbreviations automagically if that particular mode is enabled M-/: dabbrev-complete M-x abbrev-mode: enter the Abbrev minor mode Use undo to revert a completion of an abbreviation or M-x unexpand-abbrev Locally defined abbreviations are mode specific, not buffer specific! C-x a i g, C-x a -: add global abbrev C-x a i l: local abbrev (setq-default abbrev-mode t) (read-abbrev-file "~/.abbrev_defs") (setq save-abbrevs t) M-x edit-abbrevs (basically only deletion is safe) M-x list-abbrevs M-x write-abbrev-file M-x kill-all-abbrevs (temporary) Abbrev Mode am smarty enough to do intelligent capitalization of expansions C-x 5 2: new frame (setq initial-frame-alist '((top . 10) (left . 30) (width . 90) (height . 50))) (setq default-frame-alist '((width . 80) (height . 45))) C-x 5 f: edit file in new frame C-x 5 b: guess C-x 5 o, 0, 1: you get the picture M-x rename-buffer: guess C-x C-r: open file read only C-x 4 r: open file read only other window C-x 5 r: open file read only other frame C-x C-q: readonlify buffer C-x 3: split vindows vertically C-x <, >: shift windows right / left, respectively (backwards!) C-x ^: 'grow' window horizontally M-x shrink-window: shrink window horizontally C-x }: 'grow' window vertically C-x {: shrink window vertically C-x -: shrink window if larger than buffer (very handy) C-x +: equalify windows Variables window-min-height and window-min-width: guess C-x r m: set bookmark C-x r b: jump to bookmark M-x bookmark-rename M-x bookmark-delete C-x r l: list bookmarks e in the bookmarks buffer annotates a mark bookmark-search-size: set characters recorded for context on either side of bookmark M=!: execute shell command, output in buffer M-|: shell command on region, numerical argument puts results in current buffer C-c C-c: send ^C C-c C-z: send ^Z C-c C-d: send ^D C-c C-o: kill last output C-c C-r: beginning of last output C-c C-e: end of last output C-c C-p/n: move through output groups (way cool) (setq shell-file-name "/bin/zsh") (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt) M-x send-invisible Macros C-x (: begin definition C-x ): end definition C-x e: execute last macro C-x C-k: edit macro C-c C-c: escape macro edit M-x name-last-keyboard-macro: bind keyboard macro to M-x foo (prompted in minibuffer) The technology behind the awesomeness: Emacs uses fset, the function for assigning a value to the function cell of a symbol, to bind a vector consisting of those same keystrokes to a symbol. command-execute may execute macros in the form of vectors as well as functions (e.g., (command-execute 'jurassic-park)) M-x insert-kbd-macro: add Lisp definition of named macro to current buffer C-u C-x q: enter recursive edit during macro execution C-x q: macro breakpoint M-x apply-macro-to-region-lines Variable `tab-width' determines the width of hard tabs. However, most modes do not insert real tabs, or only use tabs when expedient. `indent-tabs-mode', when set to nil, will restrict intelligent indentation to using spaces. tab-stop-list determines where the tabs stop. C-j: newline-and-indent (filling will do this automagically) M-m: first non-white character in the line (just like ^ in Vi) M-^: delete-indentation; join this line and the one before, making sure to fix up whitespace and eliminating any fill prefix at the beginning of the line paragraph-start and paragraph-separate are regexps used to locate the beginnings of paragraphs (and, in the case of paragraph-separate, text that divides them). The match begins at the `left-margin' (configurable, of course), so use of the ^ anchor is inappropriate. If there is a fill prefix, then paragraphs are delimited by all lines which don't start with the fill prefix. In Text Mode, blank lines separate paragraphs. Parindent (either as a minor or major mode) will allow paragraphs beginning with indentation, and distinguished no other way. will run indent-relative (usually yucky). M-i, OTOH, will run tab-to-tab-stop (which is usually what you want in Text Mode). M-x untabify: akin to :set expandtab and :retab C-M-\: indent region (really only useful for programming) M-x fill-individual-paragraphs: (follows its own ruleset altogether, ignoring any other variables I mentioned!) fills the paragraphs in a region piecemeal rather than munging them together, considering changes in indentation to constitute paragraphs. adaptive-fill-mode determines whether adaptive filling will be used. This is desirable for programming modes where auto-filling is not wanted, but automatically filling comments intelligently with M-q *is* C-x .: set fill prefix (handy for writing slack-desc files) The variable fill-column answers to :set textwidth=foo, and can be set with a numerical argument to C-x p (set-fill-column). M-s: center line M-S: center paragraph M-x center-region Registers can save text, rectangles, positions, window configurations, or file names, and have a name which consists of a single character. C-x r R: save position of point C-x r j R: jump to position (if a buffer representing a file has died, Emacs will try to recreate it) (C-u) C-x r s R: copy (or move) region (C-u) C-x r i R: yank region (and put point after the text, mark before, rather than the other way around) M-x append/prepend-to-register: append/prepend region to register (C-u) C-x r r R: copy (or move) rectangle C-x r i R: yank rectangle C-x r w R: save the selected frame's window configuration C-x r f R: save the window configuration of all frames (C-u) C-x r j R: restore window configuration (and eliminate frames made irrelevant) (set-register ?R '(file . "path")): set register as filename C-x r j R: jump to file C-u NUMBER C-x r n R: store number in register (default value is 0) C-u NUMBER C-x r + R: increment register (negative numbers usable, default increment is 1) C-x r g R: insert number into buffer M-x view register Rectangles are defined by setting the mark at the upper-left hand corner of the rectangle and moving the point to the lower-right hand corner (although I imagine it could be reversed). Remember, cursor comes just after point. C-x r k/d: kill/delete the rectangle C-x r y: yank the rectangle (there is no ring for rectangles) C-x r o: open rectangle (fill area with whitespace and move text to the right) C-x r c: clear rectangle C-x r r/i R: save/yank rectangle to register M-x string-insert-rectangle: compare to (Ctrl-V, I in Vim) M-x sort-rectangles works on rectangles -*- mode: MODENAME; var: value; ... -*- `coding' seems to be shorthand for buffer-file-coding-system. If `mode' is used to set the major mode, it should come first, and may be used afterwards to set minor modes. The value for the pseudo-variable `eval' will be evaluated for side-effects. M-x normal-mode resets the buffer settings according to file name and type as well as local file variables In the last page: ;;; Local Variables: *** ;;; mode:text *** ;;; comment-column:0 *** ;;; comment-start: ";;; " *** ;;; comment-end:"***" *** ;;; End: *** The gratuitious asterisks are not really necessary, of course. The iso-2022-7bit seems to encode just about everything, and preserves composition of such text as Devanagari across edits. It is therefore useful for editing a file in Emacs until export to a more common format such as UTF-8 or TIS-620 is necessary. CPerl Mode: One interesting/frustrating thing about CPerl mode is constructs such as these: use constant +{ ZERO => 0, ONE => 1, TWO => 2, THREE => 3, FOUR => 4, FIVE => 5, SIX => 6, SEVEN => 7, EIGHT => 8, NINE => 9 }; # This is largely aesthetic Note that here, it is necessary to explicitly specify a hash construct with a plus sign. Otherwise, the indentation functionality will produce hideous staircase indents, thinking this is a block. 'Electricity' of natuaral pairs is controlled by the Boolean variable cperl-electric-parens and the string variable cperl-electric-parens-string. 'Electricity' of keyword expansion is controlled by the Boolean cperl-electric-keywords. C-j: CPerl mode's enhanced newline-and-indent, which is very intelligent C-c C-j: traditional newline-and-indent C-c C-t: Anglifies a traditional C-style `if' block (i.e., if (A) { B } -> B if A) C-c C-h v: short documentation in the minibuffer The Boolean cperl-electric-lbrace-space determines whether a space is automatically inserted between a dolla sign and a left brace, and likewise, cperl-electric-linefeed swaps C-j for C-c C-j. cperl-hairy enables a whole bunch of possibly awesome shit, but some of it personally annoying cperl-lazy-help-time (a numerical value measured in seconds) configures the idle-time before brief documentation appears in the minibuffer. cperl-invalid-face configures visibility of trailing \s+ cperl-clobber-mode-lists configures CPerl mode to replace perl-mode in the mode lists (although CPerl mode must be loaded to take effect) cperl-noscan-files-regexp defines files or directories to skip when generating tags files `cperl-indent-parens-as-block' will make this: use constant +{ ZERO => 0, ONE => 1, TWO => 2, THREE => 3, FOUR => 4, FIVE => 5, SIX => 6, SEVEN => 7, EIGHT => 8, NINE => 9 }; # This is largely aesthetic Look like this: use constant +{ ZERO => 0, ONE => 1, TWO => 2, THREE => 3, FOUR => 4, FIVE => 5, SIX => 6, SEVEN => 7, EIGHT => 8, NINE => 9 }; # This is largely aesthetic The Boolean cperl-auto-newline tells CPerl to enter a newline automagically where appropriate (after colons, newlines, etc.) In lines where a right parenthesis closes a parenthesis in a previous line (of the same multi-line statement), cperl-close-paren-offset is the offset for indent. M-x cperl-check-syntax checks the syntax of the current buffer, but only if you have mode-compile.el Shell Script Editing sh-backslash-region: unites several lines into a single command, neatly tying them together with backslashes. `sh-backslash-column' tells where to put them, and 'sh-backslash-align' (Boolean) tells whether to explicitly align them. sh-shell-file configures the actual shell used for execution within Sh Mode (sh-execute-region); `sh-shell' is the style of shell that applies to the current buffer. While the default value of `sh-shell' comes from 'sh-shell-file', the two are separate nonetheless sh-basic-offset configures the basic unit of indentation. sh-indentation influences indentation beyond the end of the end of the line. (Run M-x sh-basic-indent-line at the end of a line to see what I mean. Not sure of the practical import of this, though.) Tags etags generates tags files compatible with the Emacs tag utilities, although Exuberant ctags (which generates Emacs output as well) is probably superior. However, etags can be coaxed to work well with Perl with the help of an extra regexp: etags --regex='{perl}/our[ \t]*[\$@%]\([^ \t]*\)/\1/' -o SomeTagsFile *.pl Which captures global variables declared with 'our'; etags itself lacks support for them. M-x visit-tags-table sets the global value of tags-file-name, unless a number argument is given, in which case it sets a buffer-local value. The (mutually exclusive) value tags-table-list indicates a list of directories wherein Emacs should look for `TAGS' files. M-.: visit a tag C-u M-.: next alternate definition of last tag specified C-u - M-.: reverse that C-M-.: find-tag-regexp C-u C-M-.: next match for find-tag-regexp C-x 4 .: visit a tag in the other window M-x tags-search: regexp search through all of the files to which the tags file (or tags files?) refer M-,: cycle through matches in a tags search M-x tags-apropos: tags and filenames that match the regular expression given to it M-x list-tags: is supposed to list all the tags within a file, but seems not to be working presently (or, at least, doesn't work when the tags file includes other tag files) M-*: think of C-t in Normal mode with Vim Lisp mode keybindings C-M-f/b: move forwards/backwards across s-exps within the same level (includes atoms, strings, numbers, lists) C-M-p/n: move forwards/backwards across lists (and only lists) within the same level C-M-u/d: move up/down in list level C-M-@: mark sexp C-M-k: kill sexp after point C-M-a/e: beginning/end of current sexp C-M-h: mark current defun C-M-q: indent sexp C-M-x: evaluate current defun M-Tab: lisp-complete-symbol Custom Interface M-x customize-option: Customize a particular option M-x customize-group: Customize a particular group M-x customize-apropos: search for appropriate matches M-x customize-browse: convenient tree format Emacs Options --no-init-file, -q: load neither .emacs nor default.el in site configuration --no-site-file: do not load site-start.el (setq inhibit-default-init t) in .emacs Shit I Culled From Emacs FAQ (setq column-number-mode t): display column number in modeline (show-paren-mode t) for global minor mode that highlights matching natural pairs. Define an region and then do M-x underline-region for flashy highlighting as in manual pages. M-x server-start allows use of emacsclient M-g M-g: goto line ansi-color-for-comint-mode-on allows use of ANSI color sequences within a *shell* buffer. Kick ass. Another interesting trick: C-x C-a C-k C-g saves the last complex command in the kill ring for use in .emacs, what-have-you. Just make sure control characters are represented unambiguously (in vector or string form; make sure tabs are \t, etc.). C-h c (describe-key-briefly) will tell you what characters the special keys emit, so that you may bind them according to your own tastes. C-h w (where-is) finds the bindings of an explicit command C-h p (finder-by-keyword): topic-oriented browsing of Emacs packages emacsclient External programs can request Emacs to visit a file through sockets established by Emacs' server functionality. This eliminates the waste of starting a new process and centralizes editing, allowing reference to other relevant buffers within the same Emacs process, the kill ring, etc. One starts the Emacs server with, surprise, M-x server-start. The global variable `server-name' ("server" by default), can be used to distinguish servers. C-x # (server-edit) tells the server: "I'm done with this file" and moves on to any pending server buffers. By default, running server-edit within a buffer created from a server request will kill the buffer, unless it existed in the Emacs process prior to the request. This behavior, however, is configurable through setting `server-kill-new-buffers' (default of t, of course). When set to nil, the buffer will die only if the filename associated with it matches server-temp-file-regexp. Outline Mode Entry: a heading and its body Subtree: entry and those below it outline-minor-mode-prefix: key prefix for Outline minor mode outline-regexp: the regexp that matches a heading; if one uses the default value for `outline-level' (the function that computes the depth of the heading based on the match), the length of the match determines the depth of the heading and its topic, unless there exists an overriding value in `outline-heading-alist'. C-c C-n/p: move to next/previous heading line, irrespective of scope C-c C-f/b: move to next/previous heading line at same level C-c C-u: move up a level C-c C-t: like zM in Vim; show collapsed structure of headings of currently showing entries, nothing more C-c C-a: like zR in Vim; show everything C-c C-d: hides everything below the current header including its body C-c C-s: show everything below current level, inclusive C-c C-l: reduce everything below current level to collapsed headings, if currently showing -- like C-c C-t in microcosm C-c C-k: show all headings below current level -- there is a subtle difference from the previous command in that this one shows and the other hides, arriving at more or less the same end. (Open bodies will remain open with this command.) C-c C-i: show immediate subheadings (those directly below current level) C-c C-c: hide entry C-c C-e: show entry C-c C-q: hide everything except the top N levels of heading lines (use C-u) C-c C-o: hide other (everything but this and the headings of the parents) C-c C-@: mark current subtree Other Stuff M-; - indent-for-comment, useful in markup files and code. M-j will continue the comment, and I'm sure you can guess what M-x comment-region does. Try using M-x type-break-mode... C-\: toggle input method Use comint-dynamic-complete-filename for filename completion C- twice in the same place temporarily activates Transient Mark mode. Local variable specifications: similar to 'vim:ts=4' modelines in some respects. In the first (or second) line: C-x =: examine character under cursor C-M-l (reposition-window) scrolls the window in a heuristic fashion, to expose whole sections of useful material (will try to get an entire `defun' in the window if at all possible).