Emacs cool keys

= Cool Keys in Emacs/Emacs Key Combinations =
 * Source: http://www.math.uh.edu/~bgb/emacs_keys.html
 * Umodified version. Wikified headers.

Note that C-x means Control-X while M-x means Meta-X where meta may mean hitting and releasing the escape key, or alt. These keys are excerpted from the Unix in a Nutshell book. The first column has their default key binding; the second their function name; last is a short description.

File Handling Commands
C-x C-f		find-file		Find a file and read it to screen. C-x C-v		find-alternate-file	Read a different file. C-x i		insert-file		Insert a file at the cursors position. C-x C-s		save-buffer		Save the current buffer. C-x C-w		write-file		Write the contents of the buffer to a file. C-x C-c		save-buffers-kill-emacs	Save all open buffers and get out of emacs. C-z		suspend-emacs		Suspend emacs.

Cursor Movement Commands
C-f		forward-char		Move cursor one character. C-b		backward-char		Move backward one character. C-p		previous-line		Move up one line. C-n		next-line		Move down one line. M-f		forward-word		Move to the next word. (words are defined by whitespace/special characters.) M-b		backward-word		Move to the previous word. C-a		beginning-of-line	Move to the beginning of the line. C-e		end-of-line		Move to the end of the line. M-a		backward-sentence	Move back one sentence. C-v		scroll-up		Scroll up one screen. M-v		scroll-down		Scroll down one screen. C-x [		backward-page		Go back one page. C-x ]		forward-page		Go forward one page. M->		end-of-buffer		Move to end of buffer. M-<		beginning-of-buffer	Move to beginning of the current buffer. C-l		recenter		Redraw the screen with the current line in the center. M-(a number)	digit-argument		Do the next command (a number) of times.

Deletion Commands
Del		backward-delete-char	Delete the previous character. C-d		delete-char		Delete the character under the cursor. M-Del		backward-kill-word	Delete the previous word. C-k		kill-line		Delete from the cursor to the end of line. M-k		kill-sentence		Delete the sentence the cursor is in. C-x Del		backward-kill-sentence	Delete the previous sentence. C-y		yank			Restore deleted text at cursor. C-w		kill-region		Delete a marked region. backward-kill-paragraph	Delete the previous paragraph. kill-paragraph		Delete from the cursor to the end of the paragraph.

Paragraphs and Regions
C-@		set-mark		Mark the beginning (or end) of a region. C-Space		set-mark		Ibid. C-x C-p		mark-page		Mark the current page. C-x C-x		exchange-point-and-make	Exchange the location of the cursor and the mark. C-x h		mark-whole-buffer	Mark the current buffer. M-q		fill-paragraph		Reset the paragraph. M-g		fill-region		Reformat individual paragraphs with region. M-h		mark-paragraph		Mark select paragraph.

Stopping and Undoing Commands
C-g		keyboard-quit		Stop current command Now! C-x u		advertised-undo		Undo the last edit (do it often) revert-buffer		Return the buffer to the state when last autosaved.

Transposition Commands
C-t		transpose-chars		Transpose the two letters. M-t		transpose-words		Switch two words. C-x C-t		transpose-lines		Switch two lines. transpose-sentences	Switch two sentences. transpose-paragraphs	Switch two paragraphs.

Capitalization Commands
M-c		capitalize-word		Capitalize the first letter of the current word. M-u		upcase-word		Make the word all uppercase. M-l		downcase-word		Make the word all lowercase. C-x C-l		downcase-region		Make the region all lowercase. C-x C-u		uppercase-region	Make the region all uppercase.

Incremental Search Commands
C-s		isearch-forward		Start an incremental search forward. C-r		isearch-backward	Starts an incremental search in the reverse direction. Meta					Stop a successful search. C-g		keyboard-quit		Stop searching and return to the starting point. Del					Delete an incorrect character whilst searching.

Word Abbreviation Commands
abbrev-mode		Enter abbreviation mode. C-x -		inverse-add-global-abbrev	Type in a global abbreviation, then its meaning. C-x C-h		inverse-add-local-abbrev	Type in a local abbreviation, then its meaning. unexpand-abbrev		Undo the last word abbreviation. write-abbrev-file	Write out the word abbreviation file. edit-abbrevs		Edit the current word abbreviations. list-abbrevs		View the current word abbreviations. kill-all-abbrevs	Kill any abreviations for this session.

Buffer Manipulation Commands
C-x b		switch-to-buffer	Move to the specified buffer. C-x C-b		list-buffers		Display the list of currently active buffers. C-x k		kill-buffer		Kill the current buffer kill-some-buffers	Ask about deleting each buffer currently active. rename-buffer		Rename the current buffer to something else. C-x s		save-some-buffers	Ask whether to save each modified buffer

Window Commands
C-x 2		split-window-horizontally	Divide the current window horizontally in two. C-x 5		split-windws-vertically		Divide the current window vertically in two. C-x >		scroll-right			Scroll the window right. C-x <		scroll-left			Scroll the window left. C-x 0		delete-window			Delete the current window. C-x 1		delete-other-windows		Delete all the windows except this one. delete-windows-on		Delete all windows open to a particular buffer. C-x ^		enlarge-window			Make the current window taller. shrink-window			Make the current window smaller. C-x }		enlarge-window-horizontally	Make the window wider. C-x {		shrink-window-horizontally	Make the window less wide. M-C-v		scroll-other-window		Scroll the other window. C-x 4 f		find-file-other-window		Find a file in the other window. C-x 4 b		switch-to-buffer-other-window	Select a buffer in the other window. compare-windows			Compare two buffers and show the first difference.

Special Shell Characters
shell			Start a shell. C-c C-c		interrupt-shell-subjob	Terminate the current job in a shell. C-c C-d		send-shell-eof		Send the EOF character (Ctrl-d) C-c C-u		kill-shell-input	Erase the current line. C-c C-w		backward-kill-word	Erase the previous word. C-c C-z		stop-shell-subjob	Suspend the current shell job.

Indentation Commands
C-x		set-fill-prefix		Prepend each line in paragrph with characters from beginning of the line up to the current cursor column. cancel by doing this in column 1. M-C-\		indent-region		Indent a region to match the first line in region. M-m		back-to-indentation	Move the cursor to first character in line. M-C-o		split-line			Split line at cursor into two lines... weird. fill-individual-paragraphs	Reformat indented paragraphs, keep indentation.

Centering Commands
M-s		center-line		Center the current line. center-paragraph	Center the paragraph that the cursor is on. center-region		Center the currently defined region.

Macro Commands
C-x (		start-kbd-macro		Start a new macro definition.   C-x )		end-kbd-macro		End the current macro definition. C-x e		call-last-kbd-macro	Execute the last defined macro. M-(number) C-x e	call-last-kbd-maco	Do that last macro (number times). C-u C-x (	stat-kbd-macro		Execute last macro and add to it.   		name-last-kbd-macro	Name the last macro before saving it.    		insert-last-keyboard-macro	Insert the macro you made into a file.    		load-file			Load a file with macros in it.    C-x q		kbd-macro-query		Insert a query into a keyboard macro.    M-C-c		exit-recursive-edit		Get the hell out of a recursive edit.

Detail Information Help Commands
C-h a		command-apropos		What commands work like this...? apropos			What functions and variables work like this...? C-h c		describe-key-briefly	What command does this key sequence do? C-h b		describe-bindings	What are the key bindings for this buffer? C-h k		describe-key		What command does this sequence do, and tell me about it. C-h l		view-lossage		What are the last 100 characters typed? C-h w		where-is		What is the key binding for this? C-h f		describe-function	What does this function do? C-h v		describe-variable	What is this variable? C-h m		describe-mode		Tell me about this mode. C-h s		describe-syntax		What is the syntax table for this buffer?

Thanks to Ashton Trey Belew at Wesleyan for providing this file. Last modified: Mon Sep 20 10:54:19 CDT 2004

= Emacs Commands List =
 * Source: http://www.math.uh.edu/~bgb/emacs_keys.html
 * Unmodified. Wikified headers. Spaces to format paragraphs.

SourceForge Logo Emacs Commands List

C = Control M = Meta = Alt|Esc

Basics
C-x C-f "find" file i.e. open/create a file in buffer C-x C-s save the file C-x C-w write the text to an alternate name C-x C-v find alternate file C-x i insert file at cursor position C-x b create/switch buffers C-x C-b show buffer list C-x k kill buffer C-z suspend emacs C-X C-c close down emacs

Basic movement
C-f forward char C-b backward char C-p previous line C-n next line M-f forward one word M-b backward one word C-a beginning of line C-e end of line C-v one page up M-v scroll down one page M-< beginning of text M-> end of text

Editing
M-n repeat the following command n times C-u repeat the following command 4 times C-u n repeat n times C-d delete a char M-d delete word M-Del delete word backwards C-k kill line C-Space Set beginning mark (for region marking for example) C-W "kill" (delete) the marked region region M-W copy the marked region C-y "yank" (paste) the copied/killed region/line M-y yank earlier text (cycle through kill buffer) C-x C-x exchange cursor and mark C-t transpose two chars M-t transpose two words C-x C-t transpose lines M-u make letters uppercase in word from cursor position to end M-c simply make first letter in word uppercase M-l opposite to M-u

Important
C-g quit the running/entered command C-x u undo previous action M-x revert-buffer RETURN (insert like this) undo all changes since last save M-x recover-file RETURN Recover text from an autosave-file M-x recover-session RETURN if you edited several files

Online-Help
C-h c which command does this keystroke invoke C-h k which command does this keystroke invoke and what does it do? C-h l what were my last 100 typed keys C-h w what key-combo does this command have? C-h f what does this function do C-h v what's this variable and what is it's value C-h b show all keycommands for this buffer C-h t start the emacs tutorial C-h i start the info reader C-h C-k start up info reader and go to a certain key-combo point C-h F show the emacs FAQ C-h p show infos about the Elisp package on this machine

Search/Replace
C-s Search forward C-r search backward C-g return to where search started (if you are still in search mode) M-% query replace Space or y replace this occurence Del or n don't replace . only replace this and exit (replace) , replace and pause (resume with Space or y)    ! replace all following occurences ^ back to previous match RETURN or q quit replace

Search/Replace with regular expressions
Characters to use in regular expressions: ^ beginning of line $ end of line . single char .* group or null of chars \< beginning of a word \> end of a word [] every char inside the backets (for example [a-z] means every small letter) M C-s RETURN search for regular expression forward M C-r RETURN search for regular expression backward M C-s incremental search C-s repeat incremental search M C-r incremental search backwards C-r repeat backwards M-x query-replace-regexp search and replace

Window-Commands
C-x 2 split window vertically C-x o change to other window C-x 0 delete window C-x 1 close all windows except the one the cursors in C-x ^ enlarge window M-x shrink-window command says it ;-) M C-v scroll other window C-x 4 f find file in other window C-x 4 o change to other window C-x 4 0 kill buffer and window C-x 5 2 make new frame C-x 5 f find file in other frame C-x 5 o change to other frame C-x 5 0 close this frame

Bookmark commands
C-x r m set a bookmark at current cursor pos C-x r b jump to bookmark M-x bookmark-rename says it M-x bookmark-delete " M-x bookmark-save " C-x r l list bookmarks d mark bookmark for deletion r rename bookmark s save all listed bookmarks f show bookmark the cursor is over m mark bookmarks to be shown in multiple window v show marked bookmarks (or the one the cursor is over) t toggle listing of the corresponding paths w " path to this file    x delete marked bookmarks     Del ?     q quit bookmark list M-x bookmark-write write all bookmarks in given file M-x bookmark-load load bookmark from given file

DIRectory EDitor (dired)
C-x d start up dired C (large C) copy d mark for erase D delete right away e or f open file or directory g reread directory structure from file G change group permissions (chgrp) k delete line from listing on screen (don't actually delete) m mark with * n move to next line o open file in other window and go there C-o open file in other window but don't change there P print file q quit dired Q do query-replace in marked files R rename file u remove mark v view file content x delete files marked with D z compress file M-Del remove all marks (whatever kind) ~ mark backup files (name~ files) for deletion */ mark directory with * (C-u * removes that mark again) = compare this file with marked file M-= compare this file with it's backup file ! apply shell command to this file M-} change to the next file marked with * od D M-{ " previous " % d mark files described through regular expression for deletion % m " (with *) + create directory > changed to next dir < change to previous dir s toggle between sorting by name or date Maybe into this category also fits this command: M-x speedbar starts up a separate window with a directory view
 * 1) mark auto-save files (#name#) for deletion

Macro-commands
C-x ( start macro definition C-x ) end of macro definition C-x e execute last definied macro M-n C-x e execute last defined macro n times M-x name-last-kbd-macro give name to macro (for saving) M-x insert-keyboard-macro save named macro into file M-x load-file load macro M-x macroname execute macroname

Programming
M C-\ indent region between cursor and mark M-m move to first (non-space) char in this line M-^ attach this line to previous M-; formatize and indent comment C, C++ and Java Modes M-a beginning of statement M-e end of statement M C-a beginning of function M C-e end of function C-c RETURN Set cursor to beginning of function and mark at the end C-c C-q indent the whole function according to indention style C-c C-a toggle modus in which after electric signs (like {}:';./*) emacs does the indention C-c C-d toggle auto hungry mode in which emacs deletes groups of spaces with one del-press C-c C-u go to beginning of this preprocessor statement C-c C-c comment out marked area More general (I guess) M-x outline-minor-mode collapses function definitions in a file to a mere {...} M-x show-subtree If you are in one of the collapsed functions, this un-collapses it In order to achive some of the feats coming up now you have to run etags *.c *.h *.cpp (or what ever ending you source files have) in the source directory M-. (Thats Meta dot) If you are in a function call, this will take you to it's definition M-x tags-search ENTER Searches through all you etaged M-, (Meta comma) jumps to the next occurence for tags-search M-x tags-query-replace yum. This lets you replace some text in all the tagged files GDB (Debugger) M-x gdb starts up gdm in an extra window

Version Control
C-x v d show all registered files in this dir C-x v = show diff between versions C-x v u remove all changes since last checkin C-x v ~ show certain version in different window C-x v l print log C-x v i mark file for version control add C-x v h insert version control header into file C-x v r check out named snapshot C-x v s create named snapshot C-x v a create changelog file in gnu-style

NEWS 8.1.2002: The first part comes here Last update: 8.1.2002