Common default Emacs key prefixes
Key prefix Description C-c Commands particular to the current editing mode C-x Commands for files and buffers C-h Help commands M-x Literal function name C-h b Show key bindingsEmacs window-manipulation commands
Key Function Description C-x 4 f find-file-other-window Open a new file in a new buffer, drawing it in a new vertical window. undefined scroll-all-mode Toggle the scroll-all minor mode. When it's on, all windows displaying the buffer in the current window are scrolled simultaneously and in equal, relative amounts. C-x 3 split-window-horizontally Split the current window in half down the middle, stacking the new buffers horizontally. undefined follow-mode Toggle follow, a minor mode. When it's on in a buffer, all windows displaying the buffer are connected into a large virtual window. C-x ^ enlarge-window Make the current window taller by a line; preceded by a negative, this makes the current window shorter by a line. C-x } shrink-window-horizontally Make the current active window thinner by a single column. C-x { enlarge-window-horizontally Make the current active window wider by a single column. C-x - shrink-window-if-larger-than-buffer Reduce the current active window to the smallest possible size for the buffer it contains. C-x + balance-windows Balance the size of all windows, making them approximately equal. undefined compare-windows Compare the current window with the next window, beginning with point in both windows and moving point in both buffers to the first character that differs until reaching the end of the buffer.Emacs text manipulation commands
Key Function Description C-x Tab indent-rigidly This command indents lines in the region (or at point). undefined fill-region This command fills all paragraphs in the region. M-q fill-paragraph This command fills the single paragraph at point. M-\ delete-horizontal-space This command removes any horizontal space to the right and left of point. C-o open-line This command opens a new line of vertical space below point, without moving point. C-t transpose-chars This command transposes the single characters to the right and left of point. M-t transpose-words This command transposes the single words to the right and left of point. C-x C-t transpose-lines This command transposes the line at point with the line before it. M-^ delete-indentation This command joins the line at point with the previous line. Preface with C-1 to join the line at point with the next line (C-1 M-^) M-u uppercase-word This command converts the text at point to the end of the word to uppercase letters. M-l downcase-word This command converts the text at point to the end of the word to lowercase letters. C-x C-l downcase-region This command converts the region to lowercase letters. C-x C-u upcase-region This command converts the region to uppercase letters. M-m back-to-indentation This command, given anywhere on a line, positions point at the first non blank character on the line. C-s C-w This command, add the (rest of the) word at the pointer for searchEmacs commands for using registers
Emacs registers are general-purpose storage mechanisms that can store one of many things, including text, a rectangle, a position in a buffer, or some other value or setting. Every register has a label, which is a single character that you use to reference it. A register can be redefined, but it can contain only one thing at a time. Once you exit Emacs, all registers are cleared. Key Function Description C-x r space X point-to-register Save point to register named X. C-x r s X copy-to-register Save the region to register named X. C-x r r X copy-rectangle-to-register Save the selected rectangle to register named X. undefined view-register View the contents of a given register. C-x r j X jump-to-register Move point to the location given in register named X. C-x r i X insert-register Insert the contents of register named X at point.Emacs commands for using bookmarks
Emacs has another facility for saving positions in buffers. These Emacs bookmarks work the same as registers, but their labels can be longer than a single character, and they're more permanent: If you save them, you can use them between sessions. They persist until you remove them. As their name implies, bookmarks are handy for saving your position in a buffer so that you can return to it at a later time, most often during a later Emacs session. Key Function Description C-x r m Bookmark bookmark-set Set a bookmark named Bookmark. C-x r l bookmarks-bmenu-list List all saved bookmarks. undefined bookmark-delete Delete a bookmark. C-x r b Bookmark bookmark-jump Jump to the location set in the bookmark named Bookmark. undefined bookmark-save Save all bookmarks to the bookmark file, ~/.emacs.bmk. (you can redefine it)Emacs commands for using rectangles
Did you ever wish you could select a box of text from a document for copying, killing, or yanking purposes? You can. In Emacs, a selection of text specified by any two opposite of its four corners is called a rectangle. Key Function Description C-space set-mark-command Marks one corner of a rectangle (point marks the opposite corner). C-x r k kill-rectangle Kills the current rectangle and saves it in a special rectangle buffer. C-x r d delete-rectangle Deletes the current rectangle and doesn't save it for yanking. C-x r c clear-rectangle Clears the current rectangle, replacing the entire area with whitespace. C-x r o open-rectangle Opens the current rectangle, filling the entire area with whitespace and moving all text from the rectangle to the right. C-x r M-w Copy text without deleting the text from the buffer. C-x r y yank-rectangle Yanks the contents of the last-killed rectangle at point, moving all existing text to the right.Mark rings
You should never have to scroll around randomly in a buffer to find "that place you were just looking at". Whenever you take a diversion (e.g. by searching, or pressing M-< or M->), Emacs uses the mark to save your previous position, kind of like sticking your finger behind one page of a book while you go to glance at another page. You can return to the mark with C-x C-x. However, Emacs saves up to 16 previous values of the mark, and you can jump to previous ones with C-u C-SPC. This makes mark and the mark ring a valuable navigation tool. You can use it somewhat mindlessly: if you ever find yourself asking "where was I just now?" you can often just press C-u C-SPC until you find yourself back in the right place.Programming
Key Function Description M-x check-parens Checking for unmatched parentheses C-x w h REGEXP FACE Highlight matches of pattern REGEXP in current buffer with FACE. C-x w p PHRASE FACE Highlight matches of phrase PHRASE in current buffer with FACE. (PHRASE can be any REGEXP, but spaces will be replaced by matches to whitespace and initial lower-case letters will become case insensitive.) C-x w l REGEXP FACE Highlight lines containing matches of REGEXP in current buffer with FACE. C-x w r REGEX Remove highlighting on matches of REGEXP in current buffer Tips: C-SPC Make mark in some place and then disable it with C-g Go somewhere else and do it again and again etc. C-u C-SPC Back to previous mark, and back and back etc. M-x re-builder Helps you to create needed regular expression.Highlighting Regexps, Phrases, And Lines
Key Function Description M-s h p highlight-phrase It will ask you for a phrase and highlighting color and then highlight all the matching phrases in the buffer. M-s h r highlight-regexp Highlight anything that matches an arbitrary regexp M-s h l highlight-lines-matching-regexp Highlights the entire line that contains the match to the regular expression M-s h u unhighlight-regexp Un-highlight the matches Useful references: Emacs Tutorial Beyond Emacs Tutorial Reference Card
Wednesday, March 02, 2011
Advanced Emacs Commands
Subscribe to:
Post Comments (Atom)
algorithms
(1)
cpp
(3)
cv
(1)
daily
(4)
emacs
(2)
freebsd
(4)
java
(3)
javascript
(1)
JSON
(1)
linux
(2)
Lisp
(7)
misc
(8)
programming
(16)
Python
(4)
SICP
(1)
source control
(4)
sql
(1)
думи
(8)
No comments:
Post a Comment