You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

670 lines
14 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Emacs Cheatsheet</title>
<meta name="generator" content="muse.el">
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<style type="text/css">
body {
background: white; color: black;
margin-left: 3%; margin-right: 7%;
}
p { margin-top: 1% }
p.verse { margin-left: 3% }
.example { margin-left: 3% }
h2 {
margin-top: 25px;
margin-bottom: 0px;
}
h3 { margin-bottom: 0px; }
</style>
</head>
<body>
<h1>Emacs Cheatsheet</h1>
<!-- Page published by Emacs Muse begins here -->
<div class="contents">
<dl>
<dt>
<a href="#sec1">Basic Movement and Editing Commands</a>
</dt>
<dt>
<a href="#sec2">Kill &amp; Yank (Cut/Copy and Paste)</a>
</dt>
<dt>
<a href="#sec3">Search &amp; Replace</a>
</dt>
<dt>
<a href="#sec4">Emacs Modes</a>
</dt>
<dt>
<a href="#sec5">Buffers</a>
</dt>
<dt>
<a href="#sec6">Windows</a>
</dt>
<dt>
<a href="#sec7">Dired Mode</a>
</dt>
<dt>
<a href="#sec8">Shell Modes</a>
</dt>
<dt>
<a href="#sec9">Getting Help</a>
</dt>
<dt>
<a href="#sec10">w3m mode</a>
</dt>
<dt>
<a href="#sec11">Sample .emacs</a>
</dt>
</dl>
</div>
<h2><a name="sec1" id="sec1"></a>
Basic Movement and Editing Commands</h2>
<table class="muse-table" border="2" cellpadding="5">
<tbody>
<tr>
<td>C-x C-f</td>
<td>Find file and load into buffer (Emacs prompts for filename)</td>
</tr>
<tr>
<td>C-x C-s</td>
<td>Save the current buffer</td>
</tr>
<tr>
<td>C-x C-w</td>
<td>Save the current buffer under a different name (Emacs prompts for the new name)</td>
</tr>
<tr>
<td>C-x C-c</td>
<td>Quit Emacs, prompting if you have not saved any buffers</td>
</tr>
<tr>
<td>Arrow keys or C-f, C-b, C-n, C-p</td>
<td>Right (forward), left (back), down (next), up (previous), respectively</td>
</tr>
<tr>
<td>C-k</td>
<td>Delete from cursor to end of line</td>
</tr>
<tr>
<td>C-a</td>
<td>Go to start of line</td>
</tr>
<tr>
<td>C-e</td>
<td>Go to end of line</td>
</tr>
<tr>
<td>C-v</td>
<td>Go down a page</td>
</tr>
<tr>
<td>M-v</td>
<td>Go up a page</td>
</tr>
<tr>
<td>M-f</td>
<td>Go to next word</td>
</tr>
<tr>
<td>M-b</td>
<td>Go back one word</td>
</tr>
<tr>
<td>M-a</td>
<td>Go to previous sentence</td>
</tr>
<tr>
<td>M-b</td>
<td>Go to next sentence</td>
</tr>
<tr>
<td>C-/</td>
<td>Undo</td>
</tr>
<tr>
<td>C-_</td>
<td>Undo (alias for C-/) </td>
</tr>
<tr>
<td>C-x u</td>
<td>Undo (alias for C-/) </td>
</tr>
<tr>
<td>C-g</td>
<td>Abort the current command</td>
</tr>
<tr>
<td>C-l</td>
<td>Redraw and center screen at cursor</td>
</tr>
<tr>
<td>M-&lt;</td>
<td>Go to start of buffer</td>
</tr>
<tr>
<td>M-&gt;</td>
<td>Go to end of buffer</td>
</tr>
<tr>
<td>C-d</td>
<td>Delete next character</td>
</tr>
<tr>
<td>M-d</td>
<td>Delete next word</td>
</tr>
<tr>
<td>M-|</td>
<td>Execute shell command on region</td>
</tr>
<tr>
<td>Backspace</td>
<td>Delete previous character</td>
</tr>
</tbody>
</table>
<h2><a name="sec2" id="sec2"></a>
Kill &amp; Yank (Cut/Copy and Paste)</h2>
<table class="muse-table" border="2" cellpadding="5">
<tbody>
<tr>
<td>C-space</td>
<td>Set the mark</td>
</tr>
<tr>
<td>C-w</td>
<td>Cut (kill)</td>
</tr>
<tr>
<td>M-w</td>
<td>Copy (kill)</td>
</tr>
<tr>
<td>C-y</td>
<td>Paste (yank)</td>
</tr>
<tr>
<td>M-y</td>
<td>Paste (yank) next saved selection</td>
</tr>
<tr>
<td>C-x h</td>
<td>Set point to start of buffer and mark to end of buffer (select the entire buffer)</td>
</tr>
<tr>
<td>C-x C-x</td>
<td>Swap point and mark</td>
</tr>
</tbody>
</table>
<h2><a name="sec3" id="sec3"></a>
Search &amp; Replace</h2>
<table class="muse-table" border="2" cellpadding="5">
<tbody>
<tr>
<td>C-s</td>
<td>Incremental search forward</td>
</tr>
<tr>
<td>C-r</td>
<td>Incremental search backward</td>
</tr>
<tr>
<td>C-M-s</td>
<td>Regexp search forward</td>
</tr>
<tr>
<td>C-M-r</td>
<td>Regexp search backward</td>
</tr>
<tr>
<td>M-%</td>
<td>Search and replace</td>
</tr>
<tr>
<td>M-x query-replace-regexp</td>
<td>Search and replace with regexps</td>
</tr>
<tr>
<td>C-g</td>
<td>Abort a search</td>
</tr>
<tr>
<td>C-w</td>
<td>During a search, highlight the word around the cursor</td>
</tr>
<tr>
<td>Up, down arrow keys or M-p, M-n</td>
<td>Access search string history</td>
</tr>
</tbody>
</table>
<h2><a name="sec4" id="sec4"></a>
Emacs Modes</h2>
<table class="muse-table" border="2" cellpadding="5">
<tbody>
<tr>
<td>M-x modename</td>
<td>Toggle the given major or minor mode</td>
</tr>
<tr>
<td>C-h m</td>
<td>Display help on the current major mode, including any special key bindings in effect</td>
</tr>
<tr>
<td>M-q</td>
<td>Used in text-mode to reformat a paragraph of text manually</td>
</tr>
<tr>
<td>M-x global-font-lock-mode</td>
<td>Toggle syntax highlighting</td>
</tr>
</tbody>
</table>
<h2><a name="sec5" id="sec5"></a>
Buffers</h2>
<table class="muse-table" border="2" cellpadding="5">
<tbody>
<tr>
<td>C-x b</td>
<td>Switch to another buffer</td>
</tr>
<tr>
<td>C-x C-b</td>
<td>Display buffer list</td>
</tr>
<tr>
<td>C-x k</td>
<td>Kill current buffer (Emacs prompts for confirmation)</td>
</tr>
<tr>
<td>M-x iswitchb-mode</td>
<td>Enable iswitch mode, for smart buffer name completion with C-x b</td>
</tr>
</tbody>
</table>
<h2><a name="sec6" id="sec6"></a>
Windows</h2>
<table class="muse-table" border="2" cellpadding="5">
<tbody>
<tr>
<td>C-x 0</td>
<td>Close this window</td>
</tr>
<tr>
<td>C-x 1</td>
<td>Close all other visible windows</td>
</tr>
<tr>
<td>C-x 2</td>
<td>Split horizontally</td>
</tr>
<tr>
<td>C-x 3</td>
<td>Split vertically</td>
</tr>
<tr>
<td>C-x o</td>
<td>Switch to other window</td>
</tr>
<tr>
<td>C-M-v</td>
<td>Scroll other window</td>
</tr>
</tbody>
</table>
<h2><a name="sec7" id="sec7"></a>
Dired Mode</h2>
<table class="muse-table" border="2" cellpadding="5">
<tbody>
<tr>
<td>M-x dired</td>
<td>Load dired mode (Emacs prompts for directory name)</td>
</tr>
<tr>
<td>C-x C-f</td>
<td>Dired mode loaded when a directory is specified as load file</td>
</tr>
<tr>
<td>Left, right arrow keys or p, n</td>
<td>Previous and next file, respectively</td>
</tr>
<tr>
<td>Enter</td>
<td>Visit this file in this window</td>
</tr>
<tr>
<td>o</td>
<td>Visit this file in a new window</td>
</tr>
<tr>
<td>g</td>
<td>Refresh directory view</td>
</tr>
<tr>
<td>m</td>
<td>Mark file</td>
</tr>
<tr>
<td>u</td>
<td>Un-mark file</td>
</tr>
<tr>
<td>d</td>
<td>Mark a file for later deletion</td>
</tr>
<tr>
<td>x</td>
<td>Delete all files marked for deletion (Emacs prompts for confirmation)</td>
</tr>
<tr>
<td>D</td>
<td>Delete this file right now (Emacs prompts for confirmation)</td>
</tr>
<tr>
<td>C</td>
<td>Copy this file, or copy currently marked files (Emacs prompts for destination)</td>
</tr>
<tr>
<td>R</td>
<td>Rename/move this file, or rename/move currently marked files (Emacs prompts for destination)</td>
</tr>
<tr>
<td>M</td>
<td>Chmod this file, or chmod currently marked files (Emacs prompts for new permissions)</td>
</tr>
<tr>
<td>O</td>
<td>Chown this file, or chown currently marked files (Emacs prompts for new owner)</td>
</tr>
<tr>
<td>G</td>
<td>Chgrp this file, or chgrp currently marked files (Emacs prompts for new group)</td>
</tr>
<tr>
<td>+</td>
<td>Create directory (Emacs prompts for directory name)</td>
</tr>
<tr>
<td>!</td>
<td>Execute shell command on this file, or currently marked files (Emacs prompts for command)</td>
</tr>
</tbody>
</table>
<h2><a name="sec8" id="sec8"></a>
Shell Modes</h2>
<table class="muse-table" border="2" cellpadding="5">
<tbody>
<tr>
<td>M-x shell</td>
<td>Shell mode, use M-p and M-n for command history</td>
</tr>
<tr>
<td>M-x eshell</td>
<td>Cross-platform Emacs Lisp shell emulator, use arrow keys for command history</td>
</tr>
<tr>
<td>M-x ansi-term</td>
<td>Full terminal emulator, suitable for full-screen applications.</td>
</tr>
</tbody>
</table>
<h2><a name="sec9" id="sec9"></a>
Getting Help</h2>
<table class="muse-table" border="2" cellpadding="5">
<tbody>
<tr>
<td>C-h t</td>
<td>Emacs tutorial</td>
</tr>
<tr>
<td>C-h a</td>
<td>Apropos (Emacs prompts for keyword or regexp)</td>
</tr>
<tr>
<td>C-h i</td>
<td>Load info browser</td>
</tr>
<tr>
<td>C-h m</td>
<td>Display help on current mode</td>
</tr>
<tr>
<td>C-h f</td>
<td>Display help on function (Emacs prompts for function)</td>
</tr>
<tr>
<td>C-h k</td>
<td>Display help on key (Emacs prompts for key)</td>
</tr>
<tr>
<td>M-x man</td>
<td>Display a man page in a new buffer (Emacs prompts for man page)</td>
</tr>
</tbody>
</table>
<h2><a name="sec10" id="sec10"></a>
w3m mode</h2>
<table class="muse-table" border="2" cellpadding="5">
<tbody>
<tr>
<td>M-x w3m</td>
<td>Start browsing web with emacs-w3m.</td>
</tr>
<tr>
<td>q</td>
<td>Close all emacs-w3m windows, without deleting buffers.</td>
</tr>
<tr>
<td>Q</td>
<td>Exit browsing web. All emacs-w3m buffers will be deleted.</td>
</tr>
<tr>
<td>RET</td>
<td>Display the page pointed to by the link under point.</td>
</tr>
<tr>
<td>C-c C-c</td>
<td>Submit the form at point.</td>
</tr>
<tr>
<td>R</td>
<td>Reload the current page.</td>
</tr>
<tr>
<td>r</td>
<td>Redisplay the current page.</td>
</tr>
<tr>
<td>TAB</td>
<td>Move the point to the next anchor.</td>
</tr>
<tr>
<td>M-TAB</td>
<td>Move the point to the previous anchor.</td>
</tr>
<tr>
<td>B</td>
<td>Move back to the previous page in the history.</td>
</tr>
<tr>
<td>N</td>
<td>Move forward to the next page in the history.</td>
</tr>
<tr>
<td>U</td>
<td>Visit the web page.</td>
</tr>
<tr>
<td>H</td>
<td>Go to the Home page.</td>
</tr>
<tr>
<td>M-d</td>
<td>Download the URL.</td>
</tr>
<tr>
<td>d</td>
<td>Download the URL under point.</td>
</tr>
<tr>
<td>\</td>
<td>Display the html source of the current page.</td>
</tr>
<tr>
<td>SPC</td>
<td>Scroll up the current window, or go to the next page.</td>
</tr>
<tr>
<td>b</td>
<td>Scroll down the current window, or go to the previous page.</td>
</tr>
<tr>
<td>&gt;</td>
<td>Scroll to the left.</td>
</tr>
<tr>
<td>&lt;</td>
<td>Scroll to the right.</td>
</tr>
<tr>
<td>.</td>
<td>Shift to the left.</td>
</tr>
<tr>
<td>,</td>
<td>Shift to the right.</td>
</tr>
<tr>
<td>M-l</td>
<td>Recenter horizontally.</td>
</tr>
<tr>
<td>j</td>
<td>Next line.</td>
</tr>
<tr>
<td>k</td>
<td>Previous line.</td>
</tr>
<tr>
<td>l</td>
<td>Forward char.</td>
</tr>
<tr>
<td>h</td>
<td>Backward char.</td>
</tr>
<tr>
<td>s</td>
<td>Display the history of pages you have visited in the session.</td>
</tr>
<tr>
<td>S</td>
<td>Prompt for a search query and submit it to google.</td>
</tr>
<tr>
<td>v</td>
<td>Display the bookmarks list.</td>
</tr>
<tr>
<td>a</td>
<td>Add a url of the current page to a new bookmark.</td>
</tr>
<tr>
<td>M-a</td>
<td>Add the url under point to a new bookmark.</td>
</tr>
</tbody>
</table>
<h2><a name="sec11" id="sec11"></a>
Sample .emacs</h2>
<pre class="example">
;; Sample ~/.emacs file
;;
;; Un-comment what you want to enable and re-start Emacs
;;
;;Load iswitch mode
;;(require 'iswitchb)
;;Make text mode the default for new buffers
;;(setq default-major-mode 'text-mode)
;;Turn on refill-mode whenever text mode is entered
;;(add-hook 'text-mode-hook
;; '(lambda () (refill-mode 1)))
;;Enable syntax highlighting when it's allowed
;;(when (fboundp 'global-font-lock-mode)
;; (global-font-lock-mode t))
;;Fix the backspace key
;;(normal-erase-is-backspace-mode 1)
;;Use cperl-mode for editing Perl code, it is better than perl-mode
;;(defalias 'perl-mode 'cperl-mode)
;;Don't blink my cursor, please
;;(blink-cursor-mode nil)
;;Display the current time in the modeline
;;(display-time-mode t)
;;Start the emacs server
;;
;;When this is running, programs calling emacsclient open a buffer
;;in the already running emacs. Useful in mutt or pine for composing
;;mail in Emacs. Type C-x # to exit client buffer and send the text
;;back to the application that called it.
;;(server-start)
</pre>
<center>
<p>$Id: emacs-cheatsheet.html,v 1.4 2013/01/18 11:00:13 nullogic Exp $</p>
</center>
<!-- Page published by Emacs Muse ends here -->
</body>
</html>