<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8"/> <link rel="icon" type="image/gif" href="favicon.gif"/> <link rel="apple-touch-icon" sizes="120x120" href="touch-icon-iphone-retina.png" /> <link rel="apple-touch-icon" sizes="152x152" href="touch-icon-ipad-retina.png" /> <title>Text Mode Editors: Vim, Emacs, Nano - Hyperpolyglot</title> <style type="text/css" id="internal-style"> @import url(hyperpolyglot.css); </style> <meta http-equiv="content-type" content="text/html;charset=UTF-8"/> <meta http-equiv="content-language" content="en"/> </head> <body> <div id="container-wrap-wrap"> <div id="container-wrap"> <div id="container"> <div id="header"> <h1><a href="index.html"><span>Hyperpolyglot</span></a></h1> </div> <div id="content-wrap"> <div id="main-content"> <div id="page-title"> Text Mode Editors: Vim, Emacs, Nano </div> <div id="page-content"> <p><a name="top" id="top"></a><strong>text editing:</strong> <a href="text-mode-editors#mode">mode</a> | <a href="text-mode-editors#movement">movement</a> | <a href="text-mode-editors#selecting-deleting">selecting</a> | <a href="text-mode-editors#selecting-deleting">deleting</a> | <a href="text-mode-editors#files-buffers">files</a> | <a href="text-mode-editors#files-buffers">buffers</a> | <a href="text-mode-editors#minibuffer">minibuffer</a> | <a href="text-mode-editors#ido">ido</a> | <a href="text-mode-editors#history">history</a> | <a href="text-mode-editors#searching-replacing">searching</a> | <a href="text-mode-editors#searching-replacing">replacing</a> | <a href="text-mode-editors#sorting">sorting</a> | <a href="text-mode-editors#counting">counting</a> | <a href="text-mode-editors#case">case</a> | <a href="text-mode-editors#indentation">indentation</a> | <a href="text-mode-editors#indentation">rectangles</a> | <a href="text-mode-editors#spelling">spelling</a> | <a href="text-mode-editors#panes">panes</a> | <a href="text-mode-editors#macros">macros</a> | <a href="text-mode-editors#ascii-art">ascii art</a> | <a href="text-mode-editors#org">org</a> | <a href="text-mode-editors#intl">input methods</a> | <a href="text-mode-editors#intl">encodings</a> | <a href="text-mode-editors#help">help</a></p> <p><strong>dev tools:</strong> <a href="text-mode-editors#browse-files">browse files</a> | <a href="text-mode-editors#shell">shell</a> | <a href="text-mode-editors#grep">grep</a> | <a href="text-mode-editors#tags">tags</a> | <a href="text-mode-editors#diff">diff</a> | <a href="text-mode-editors#git">git</a> | <a href="text-mode-editors#compile">compile</a> | <a href="text-mode-editors#debug">debug</a> | <a href="text-mode-editors#lisp-interaction">lisp interaction</a> | <a href="text-mode-editors#syntax-highlighting">syntax highlighting</a></p> <p><strong>programming:</strong> <a href="text-mode-editors#variables">variables</a> | <a href="text-mode-editors#arith-logic">arithmetic and logic</a> | <a href="text-mode-editors#str">strings</a> | <a href="text-mode-editors#list">lists</a> | <a href="text-mode-editors#dict">dictionaries</a> | <a href="text-mode-editors#func">functions</a> | <a href="text-mode-editors#exec-ctrl">execution control</a> | <a href="text-mode-editors#lib-mod">libraries and namespaces</a></p> <p><strong>other topics:</strong> <a href="text-mode-editors#doc">documentation</a> | <a href="text-mode-editors#terminology">terminology</a> | <a href="text-mode-editors#line-editors">line editors</a> | <a href="text-mode-editors#bindings-other-apps">bindings in other apps</a></p> <table class="wiki-content-table"> <tr> <th colspan="5"><a name="startup" id="startup"></a><a href="text-mode-editors#startup-note">startup</a></th> </tr> <tr> <th></th> <th><a href="text-mode-editors#vim">vim</a></th> <th colspan="2"><a href="text-mode-editors#emacs">emacs</a></th> <th><a href="text-mode-editors#nano">nano</a></th> </tr> <tr> <td><a name="launch" id="launch"></a><a href="text-mode-editors#launch-note">launch</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>$ vim</td> <td colspan="2">$ emacs</td> <td>$ nano</td> </tr> <tr> <td><a name="open-file-cmdline" id="open-file-cmdline"></a><a href="text-mode-editors#open-file-cmdline-note">open file</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>$ vim <span style="color: gray"><em>file</em></span></td> <td colspan="2">$ emacs <span style="color: gray"><em>file</em></span></td> <td>$ nano <span style="color: gray"><em>file</em></span></td> </tr> <tr> <td><a name="open-file-line" id="open-file-line"></a><a href="text-mode-editors#open-file-line-note">open file on line 100</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>$ vim +100 <span style="color: gray"><em>file</em></span></td> <td colspan="2">$ emacs +100 <span style="color: gray"><em>file</em></span></td> <td>$ nano +100 <span style="color: gray"><em>file</em></span></td> </tr> <tr> <td><a name="open-file-column-line" id="open-file-column-line"></a><a href="text-mode-editors#open-file-column-line-note">open file on column 20 of line 100</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>$ vim +100 -c 'normal 20|' <span style="color: gray"><em>file</em></span></td> <td colspan="2">$ emacs +100:20 <span style="color: gray"><em>file</em></span></td> <td>$ nano +100,20 <span style="color: gray"><em>file</em></span></td> </tr> <tr> <td><a name="open-file-read-only-cmdline" id="open-file-read-only-cmdline"></a><a href="text-mode-editors#open-file-read-only-cmdline-note">open file in read-only mode</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>$ vim -R <span style="color: gray"><em>file</em></span></td> <td colspan="2"></td> <td>$ nano -v <span style="color: gray"><em>file</em></span></td> </tr> <tr> <td><a name="open-multiple-files" id="open-multiple-files"></a><a href="text-mode-editors#open-multiple-files-note">open multiple files</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>$ vim <span style="color: gray"><em>file1 file2 …</em></span><br /> <br /> <span style="color: gray"><em>only first file is displayed; use</em> :bn <em>and</em> :bp <em>to change buffers;</em> :ls <em>to list buffers</em></span></td> <td colspan="2">$ emacs <span style="color: gray"><em>file1 file2 …</em></span><br /> <br /> <span style="color: gray"><em>window is split into two panes; if more than two files, one of the panes is a buffer list; use</em> C-x o <em>to switch panes; use</em> C-x b <em>to switch buffers</em></span></td> <td>$ nano <span style="color: gray"><em>file1 file2 …</em></span><br /> <br /> <span style="color: gray"><em>only first file is displayed; use</em> M-> <em>and</em> M-< <em>to change buffers</em></span></td> </tr> <tr> <td><a name="open-dir-cmdline" id="open-dir-cmdline"></a><a href="text-mode-editors#open-dir-cmdline-note">open directory</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>$ vim <span style="color: gray"><em>dir</em></span></td> <td colspan="2">$ emacs <span style="color: gray"><em>dir</em></span></td> <td></td> </tr> <tr> <td><a name="startup-file" id="startup-file"></a><a href="text-mode-editors#startup-file-note">startup file</a></td> <td>~/.vimrc</td> <td colspan="2">~/.emacs<br /> ~/.emacs.el<br /> ~/.emacs.d/init.el</td> <td>~/.nanorc</td> </tr> <tr> <td><a name="skip-startup-file" id="skip-startup-file"></a><a href="text-mode-editors#skip-startup-file-note">skip startup file</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>$ vim -u NONE</td> <td colspan="2">$ emacs -q</td> <td>$ nano -I</td> </tr> <tr> <th colspan="5"><a name="text-editing" id="text-editing"></a><a href="text-mode-editors#text-editing-note">text editing</a></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="show-version" id="show-version"></a><a href="text-mode-editors#show-version-note">show version</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:version</td> <td></td> <td>M-x emacs-version</td> <td></td> </tr> <tr> <td><a name="redraw-display" id="redraw-display"></a><a href="text-mode-editors#redraw-display-note">redraw display</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>C-l</td> <td></td> <td>M-x redraw-display</td> <td></td> </tr> <tr> <td><a name="insert-x" id="insert-x"></a><a href="text-mode-editors#insert-x-note">insert 'x'</a></td> <td><span style="color: gray"><em>insert mode:</em></span><br /> x</td> <td>x</td> <td></td> <td>x</td> </tr> <tr> <td><a name="insert-unicode-point" id="insert-unicode-point"></a><a href="text-mode-editors#insert-unicode-point-note">insert by unicode point</a></td> <td><span style="color: gray"><em>insert mode:</em></span><br /> C-v u 03c0</td> <td>C-x 8 RET 03c0 RET</td> <td>M-x ucs-insert 03c0 RET</td> <td></td> </tr> <tr> <td><a name="insert-unicode-name" id="insert-unicode-name"></a><a href="text-mode-editors#insert-unicode-name-note">insert by unicode name</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td>C-x 8 RET greek small letter pi RET</td> <td>M-x ucs-insert greek small letter pi RET</td> <td></td> </tr> <tr> <td><a name="get-unicode-point" id="get-unicode-point"></a><a href="text-mode-editors#get-unicode-point-note">get unicode point</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td></td> <td>M-x describe-char</td> <td></td> </tr> <tr> <td><a name="cancel" id="cancel"></a><a href="text-mode-editors#cancel-note">cancel</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>ESC</td> <td>C-g</td> <td>M-x keyboard-quit</td> <td></td> </tr> <tr> <td><a name="insert-control" id="insert-control"></a><a href="text-mode-editors#insert-control-note">insert control character</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>C-v <span style="color: gray"><em>char</em></span></td> <td>C-q <span style="color: gray"><em>char</em></span></td> <td>M-x quoted-insert <span style="color: gray"><em>char</em></span></td> <td>M-v</td> </tr> <tr> <td><a name="insert-newline" id="insert-newline"></a><a href="text-mode-editors#insert-newline-note">insert newline</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>C-v RET</td> <td>C-q C-j</td> <td></td> <td></td> </tr> <tr> <td><a name="auto-complete" id="auto-complete"></a><a href="text-mode-editors#auto-complete-note">auto complete</a></td> <td>C-n<br /> C-p</td> <td>M-/</td> <td>M-x hippie-expand</td> <td></td> </tr> <tr> <td><a name="repeat-n" id="repeat-n"></a><a href="text-mode-editors#repeat-n-note">repeat next command n times</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td><span style="color: gray"><em>n</em></span></td> <td>C-u <span style="color: gray"><em>n</em></span></td> <td>M-x universal-argument <span style="color: gray"><em>n</em></span></td> <td></td> </tr> <tr> <td><a name="repeat-4" id="repeat-4"></a><a href="text-mode-editors#repeat-4-note">repeat 4 times</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>4</td> <td>C-u</td> <td>M-x universal-argument</td> <td></td> </tr> <tr> <td><a name="repeat-16" id="repeat-16"></a><a href="text-mode-editors#repeat-16-note">repeat 16 times</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>16</td> <td>C-u C-u</td> <td></td> <td></td> </tr> <tr> <td><a name="font-size" id="font-size"></a><a href="text-mode-editors#font-size-note">font size</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td><span style="color: gray"><em>use menu or OS</em></span></td> <td>C-x C-=, C-x C<span style="white-space: pre-wrap;">--</span></td> <td>M-x text-scale-adjust</td> <td></td> </tr> <tr> <td><a name="exit" id="exit"></a><a href="text-mode-editors#exit-note">exit</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:q</td> <td>C-x C-c</td> <td>M-x save-buffers-kill-terminal</td> <td>C-x</td> </tr> <tr> <td><a name="save-exit" id="save-exit"></a><a href="text-mode-editors#save-exit-note">save changes and exit</a></td> <td>ZZ<br /> :wq</td> <td>C-x C-s C-x C-c</td> <td>M-x save-buffer<br /> M-x save-buffers-kill-terminal</td> <td></td> </tr> <tr> <td><a name="discard-exit" id="discard-exit"></a><a href="text-mode-editors#discard-exit-note">discard changes and exit</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:q!</td> <td></td> <td>M-x kill-emacs</td> <td></td> </tr> <tr> <th colspan="5"><a name="mode" id="mode"></a><strong><a href="text-mode-editors#mode-note">mode</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="change-mode" id="change-mode"></a><a href="text-mode-editors#change-mode-note">change mode</a></td> <td><span style="color: gray"><em>normal to insert:</em></span><br /> a, i, o, O<br /> <br /> <span style="color: gray"><em>back to normal:</em></span><br /> ESC</td> <td></td> <td>M-x <span style="color: gray"><em>mode-name</em></span></td> <td></td> </tr> <tr> <td><a name="show-mode" id="show-mode"></a><a href="text-mode-editors#show-mode-note">show mode</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td><span style="color: gray"><em>insert, visual, select, and replace indicated on bottom line</em></span></td> <td><span style="color: gray"><em>displayed on mode line</em></span></td> <td>M-: major-mode</td> <td></td> </tr> <tr> <td><a name="mode-doc" id="mode-doc"></a><a href="text-mode-editors#mode-doc-note">mode documentation</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td>C-h m</td> <td>M-x describe-mode</td> <td></td> </tr> <tr> <td><a name="set-key-binding" id="set-key-binding"></a><a href="text-mode-editors#set-key-binding-note">set key binding</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:map <span style="color: gray"><em>key</em></span> <span style="color: gray"><em>cmd</em></span></td> <td></td> <td>M-x global-set-key RET <span style="color: gray"><em>key</em></span> <span style="color: gray"><em>cmd</em></span></td> <td></td> </tr> <tr> <td><a name="enter-insert" id="enter-insert"></a><a href="text-mode-editors#enter-insert-note">enter insert mode</a><br /> <span style="color: gray"><em>before cursor, after cursor</em></span></td> <td>i<br /> a</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="enter-insert-adjacent-line" id="enter-insert-adjacent-line"></a><a href="text-mode-editors#enter-insert-adjacent-line-note">enter insert mode on adjacent line</a><br /> <span style="color: gray"><em>above current line, below current line</em></span></td> <td>o<br /> O</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="ex-mode" id="ex-mode"></a><a href="text-mode-editors#ex-mode-note">enter and exit ex mode</a></td> <td>Q<br /> :vi</td> <td></td> <td></td> <td></td> </tr> <tr> <th colspan="5"><a name="movement" id="movement"></a><strong><a href="text-mode-editors#movement-note">movement</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="point-location" id="point-location"></a><a href="text-mode-editors#point-location-note">location of point</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>C-g</td> <td>C-x =</td> <td>M-x what-cursor-position</td> <td>C-c</td> </tr> <tr> <td><a name="swap-point-mark" id="swap-point-mark"></a><a href="text-mode-editors#swap-point-mark-note">swap point and mark</a></td> <td><span style="color: gray"><em>visual mode:</em></span><br /> o</td> <td>C-x C-x</td> <td>M-x exchange-point-and-mark</td> <td></td> </tr> <tr> <td><a name="goto-line" id="goto-line"></a><a href="text-mode-editors#goto-line-note">goto line</a></td> <td>42G<br /> :42</td> <td>M-g M-g</td> <td>M-x goto-line</td> <td>C-_<br /> M-g</td> </tr> <tr> <td><a name="goto-char" id="goto-char"></a><a href="text-mode-editors#goto-char-note">goto character</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:goto <span style="color: gray"><em>n</em></span></td> <td></td> <td>M-x goto-char</td> <td></td> </tr> <tr> <td><a name="down" id="down"></a><a href="text-mode-editors#down-note">down</a></td> <td>j<br /> ↓</td> <td>C-n<br /> ↓</td> <td>M-x next-line</td> <td>C-n<br /> ↓</td> </tr> <tr> <td><a name="up" id="up"></a><a href="text-mode-editors#up-note">up</a></td> <td>k<br /> ↑</td> <td>C-p<br /> ↑</td> <td>M-x previous-line</td> <td>C-p<br /> ↑</td> </tr> <tr> <td><a name="forward" id="forward"></a><a href="text-mode-editors#forward-note">forward</a></td> <td>i<br /> →</td> <td>C-f<br /> →</td> <td>M-x forward-char<br /> M-x right-char</td> <td>C-f<br /> →</td> </tr> <tr> <td><a name="backward" id="backward"></a><a href="text-mode-editors#backward-note">backward</a></td> <td>h<br /> ←</td> <td>C-b<br /> ←</td> <td>M-x backward-char<br /> M-x left-char</td> <td>C-b<br /> ←</td> </tr> <tr> <td><a name="forward-word" id="forward-word"></a><a href="text-mode-editors#forward-word-note">forward beginning of word</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>w <span style="color: gray"><em>bigger word:</em></span> W</td> <td></td> <td></td> <td>C-SPACE</td> </tr> <tr> <td><a name="forward-word-end" id="forward-word-end"></a><a href="text-mode-editors#forward-word-end-note">forward end of word</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>e <span style="color: gray"><em>bigger word:</em></span> E</td> <td>M-f</td> <td>M-x forward-word</td> <td></td> </tr> <tr> <td><a name="backward-word" id="backward-word"></a><a href="text-mode-editors#backward-word-note">backward word</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>b <span style="color: gray"><em>bigger word:</em></span> B</td> <td>M-b</td> <td>M-x backward-word</td> <td>M-SPACE</td> </tr> <tr> <td><a name="beginning-line" id="beginning-line"></a><a href="text-mode-editors#beginning-line-note">beginning of line</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>0</td> <td>C-a</td> <td>M-x move-beginning-of-line</td> <td>C-a</td> </tr> <tr> <td><a name="beginning-line-nonblank" id="beginning-line-nonblank"></a><a href="text-mode-editors#beginning-line-nonblank-note">first nonblank character of line</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>^</td> <td>M-m</td> <td>M-x back-to-indentation</td> <td></td> </tr> <tr> <td><a name="end-line" id="end-line"></a><a href="text-mode-editors#end-line-note">end of line</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>$</td> <td>C-e</td> <td>M-x move-end-of-line</td> <td>C-e</td> </tr> <tr> <td><a name="prev-sentence" id="prev-sentence"></a><a href="text-mode-editors#prev-sentence-note">previous sentence</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>(</td> <td>M-a</td> <td>M-x backward-sentence</td> <td></td> </tr> <tr> <td><a name="next-sentence" id="next-sentence"></a><a href="text-mode-editors#next-sentence-note">next sentence</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>)</td> <td>M-e</td> <td>M-x forward-sentence</td> <td></td> </tr> <tr> <td><a name="start-paragraph" id="start-paragraph"></a><a href="text-mode-editors#start-paragraph-note">start of paragraph</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>{</td> <td>M-{<br /> C-↑</td> <td>M-x backward-paragraph</td> <td>M-(</td> </tr> <tr> <td><a name="end-paragraph" id="end-paragraph"></a><a href="text-mode-editors#end-paragraph-note">end of paragraph</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>}</td> <td>M-}<br /> C-↓</td> <td>M-x forward-paragraph</td> <td>M-)</td> </tr> <tr> <td><a name="matching-paren" id="matching-paren"></a><a href="text-mode-editors#matching-paren-note">matching paren, bracket, or brace</a></td> <td>%</td> <td>C-M-n<br /> C-M-p</td> <td>M-x forward-list<br /> M-x backward-list</td> <td>M-]</td> </tr> <tr> <td><a name="column-20" id="column-20"></a><a href="text-mode-editors#column-20-note">column 20</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>20 |</td> <td>M-g TAB 20</td> <td>M-x move-to-column RET 20</td> <td>C-_ ,20</td> </tr> <tr> <td><a name="page-down" id="page-down"></a><a href="text-mode-editors#page-down-note">page down</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>C-f</td> <td>C-v</td> <td>M-x scroll-up</td> <td>C-v</td> </tr> <tr> <td><a name="page-up" id="page-up"></a><a href="text-mode-editors#page-up-note">page up</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>C-b</td> <td>M-v</td> <td>M-x scroll-down</td> <td>C-y</td> </tr> <tr> <td><a name="half-page-down" id="half-page-down"></a><a href="text-mode-editors#half-page-down-note">half page down</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>C-d</td> <td>M-r M-r M-r C-l</td> <td></td> <td></td> </tr> <tr> <td><a name="half-page-up" id="half-page-up"></a><a href="text-mode-editors#half-page-up-note">half page up</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>C-u</td> <td>M-r M-r C-l</td> <td></td> <td></td> </tr> <tr> <td><a name="page-other-window" id="page-other-window"></a><a href="text-mode-editors#page-other-window-note">page other window</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td>C-M-v</td> <td>M-x scroll-other-window</td> <td></td> </tr> <tr> <td><a name="page-right" id="page-right"></a><a href="text-mode-editors#page-right-note">page right</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td>C-x <</td> <td></td> <td></td> </tr> <tr> <td><a name="page-left" id="page-left"></a><a href="text-mode-editors#page-left-note">page left</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td>C-x ></td> <td></td> <td></td> </tr> <tr> <td><a name="center-window" id="center-window"></a><a href="text-mode-editors#center-window-note">center window</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>zz</td> <td>C-l</td> <td>M-x recenter-top-bottom</td> <td></td> </tr> <tr> <td><a name="center-point" id="center-point"></a><a href="text-mode-editors#center-point-note">center point</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>M<br /> H<br /> L</td> <td>M-r</td> <td>M-x move-to-window-line-top-bottom</td> <td></td> </tr> <tr> <td><a name="beginning-doc" id="beginning-doc"></a><a href="text-mode-editors#beginning-doc-note">beginning of document</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>1G<br /> :1</td> <td>M-<</td> <td>M-x beginning-of-buffer</td> <td>M-\</td> </tr> <tr> <td><a name="end-doc" id="end-doc"></a><a href="text-mode-editors#end-doc-note">end of document</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>G<br /> :$</td> <td>M-></td> <td>M-x end-of-buffer</td> <td>M-/</td> </tr> <tr> <th colspan="5"><a name="selecting-deleting" id="selecting-deleting"></a><strong><a href="text-mode-editors#selecting-deleting-note">selecting and deleting</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="mark" id="mark"></a><a href="text-mode-editors#mark-note">mark</a></td> <td>v<br /> V</td> <td>C-SPACE<br /> C-@</td> <td>M-x set-mark-command</td> <td>C-^<br /> M-a</td> </tr> <tr> <td><a name="mark-rectangular-region" id="mark-rectangular-region"></a><a href="text-mode-editors#mark-rectangular-region-note">mark rectangular region</a></td> <td>C-v</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="mark-buffer" id="mark-buffer"></a><a href="text-mode-editors#mark-buffer-note">mark whole buffer</a></td> <td>ggVG</td> <td></td> <td>M-x mark-whole-buffer</td> <td></td> </tr> <tr> <td><a name="del-next-char" id="del-next-char"></a><a href="text-mode-editors#del-next-char-note">delete next char</a></td> <td>x</td> <td>C-d</td> <td>M-x delete-char</td> <td>C-d</td> </tr> <tr> <td><a name="del-prev-char" id="del-prev-char"></a><a href="text-mode-editors#del-prev-char-note">delete previous char</a></td> <td>X</td> <td>DEL</td> <td>M-x delete-backward-char</td> <td>C-h</td> </tr> <tr> <td><a name="del-next-word" id="del-next-word"></a><a href="text-mode-editors#del-next-word-note">delete next word</a></td> <td>dw</td> <td>M-d</td> <td>M-x kill-word</td> <td></td> </tr> <tr> <td><a name="del-prev-word" id="del-prev-word"></a><a href="text-mode-editors#del-prev-word-note">delete previous word</a></td> <td></td> <td>M-DEL</td> <td>M-x backward-kill-word</td> <td></td> </tr> <tr> <td><a name="delete-to-char" id="delete-to-char"></a><a href="text-mode-editors#delete-to-char-note">delete to char</a></td> <td></td> <td>M-z</td> <td>M-x zap-to-char</td> <td></td> </tr> <tr> <td><a name="del-line" id="del-line"></a><a href="text-mode-editors#del-line-note">delete to end of line</a></td> <td>d$<br /> D</td> <td>C-k</td> <td>M-x kill-line</td> <td></td> </tr> <tr> <td><a name="delete-line" id="delete-line"></a><a href="text-mode-editors#delete-line-note">delete line</a></td> <td>dd</td> <td>C-a C-k C-k</td> <td></td> <td>C-k</td> </tr> <tr> <td><a name="delete-newline" id="delete-newline"></a><a href="text-mode-editors#delete-newline-note">delete newline</a></td> <td><span style="color: gray"><em>point on line:</em></span><br /> J</td> <td><span style="color: gray"><em>point on line:</em></span><br /> C-e C-d<br /> <span style="color: gray"><em>point on following line:</em></span><br /> C-a DEL</td> <td></td> <td></td> </tr> <tr> <td><a name="copy-line" id="copy-line"></a><a href="text-mode-editors#copy-line-note">copy line</a><br /> <br /> <span style="color: gray"><em>vim calls this yank</em></span></td> <td>yy</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="kill-region" id="kill-region"></a><a href="text-mode-editors#kill-region-note">kill region</a></td> <td><span style="color: gray"><em>visual mode:</em></span><br /> d</td> <td>C-w</td> <td>M-x kill-region</td> <td></td> </tr> <tr> <td><a name="copy-region" id="copy-region"></a><a href="text-mode-editors#copy-region-note">copy region</a></td> <td><span style="color: gray"><em>visual mode:</em></span><br /> y</td> <td>M-w</td> <td>M-x kill-ring-save</td> <td>M-a<br /> M-6</td> </tr> <tr> <td><a name="paste" id="paste"></a><a href="text-mode-editors#paste-note">paste</a><br /> <br /> <span style="color: gray"><em>emacs calls this yank</em></span></td> <td>p<br /> P</td> <td>C-y</td> <td>M-x yank</td> <td>C-u</td> </tr> <tr> <td><a name="replace-paste-prev-copy" id="replace-paste-prev-copy"></a><a href="text-mode-editors#replace-paste-prev-copy-note">replace paste with previous copy</a></td> <td></td> <td>M-y</td> <td>M-x yank-pop</td> <td></td> </tr> <tr> <td><a name="paste-line-adjacent-current" id="paste-line-adjacent-current"></a><a href="text-mode-editors#paste-line-adjacent-current-note">paste line below/above current line</a></td> <td><span style="color: gray"><em>if buffer populated by</em> dd <em>or</em> yy:</span><br /> p<br /> P</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="delete-lines-regex" id="delete-lines-regex"></a><a href="text-mode-editors#delete-lines-regex-note">delete lines matching regexp</a></td> <td></td> <td></td> <td>M-x flush-lines</td> <td></td> </tr> <tr> <td><a name="delete-lines-not-matching-regex" id="delete-lines-not-matching-regex"></a><a href="text-mode-editors#delete-lines-not-matching-regex-note">delete lines not matching regexp</a></td> <td></td> <td></td> <td>M-x keep-lines</td> <td></td> </tr> <tr> <td><a name="system-copy" id="system-copy"></a><a href="text-mode-editors#system-copy-note">system copy</a></td> <td>C-c <span style="color: gray"><em>or</em></span> ⌘c</td> <td></td> <td>M-x clipboard-kill-ring-save</td> <td></td> </tr> <tr> <td><a name="system-paste" id="system-paste"></a><a href="text-mode-editors#system-paste-note">system paste</a></td> <td>C-v <span style="color: gray"><em>or</em></span> ⌘v</td> <td></td> <td>M-x clipboard-yank</td> <td></td> </tr> <tr> <td><a name="system-cut" id="system-cut"></a><a href="text-mode-editors#system-cut-note">system cut</a></td> <td></td> <td></td> <td>M-x clipboard-kill-region</td> <td></td> </tr> <tr> <th colspan="5"><a name="files-buffers" id="files-buffers"></a><strong><a href="text-mode-editors#files-buffers-note">files and buffers</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="pwd" id="pwd"></a><a href="text-mode-editors#pwd-note">show current directory</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:!pwd</td> <td></td> <td>M-! pwd</td> <td></td> </tr> <tr> <td><a name="cd" id="cd"></a><a href="text-mode-editors#cd-note">change current directory</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:cd <span style="color: gray"><em>dir</em></span></td> <td></td> <td>M-x cd</td> <td></td> </tr> <tr> <td><a name="open-file" id="open-file"></a><a href="text-mode-editors#open-file-note">open file</a></td> <td>:e <span style="color: gray"><em>path</em></span></td> <td>C-x C-f</td> <td>M-x find-file<br /> M-x ido-find-file</td> <td>C-r</td> </tr> <tr> <td><a name="open-file-read-only" id="open-file-read-only"></a><a href="text-mode-editors#open-file-read-only-note">open file read only</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:view <span style="color: gray"><em>path</em></span></td> <td>C-x C-r</td> <td>M-x find-file-read-only</td> <td></td> </tr> <tr> <td><a name="buffer-read-only" id="buffer-read-only"></a><a href="text-mode-editors#buffer-read-only-note">toggle buffer read only</a></td> <td></td> <td></td> <td>M-x read-only-mode</td> <td></td> </tr> <tr> <td><a name="show-buffer-file-name" id="show-buffer-file-name"></a><a href="text-mode-editors#show-buffer-file-name-note">show buffer file name</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:echo bufname("%")</td> <td></td> <td>M-: buffer-file-name</td> <td></td> </tr> <tr> <td><a name="list-buffers" id="list-buffers"></a><a href="text-mode-editors#list-buffers-note">list buffers</a></td> <td>:ls</td> <td>C-x C-b</td> <td>M-x list-buffers<br /> M-x buffer-menu</td> <td></td> </tr> <tr> <td><a name="switch-buffer" id="switch-buffer"></a><a href="text-mode-editors#switch-buffer-note">switch buffer</a></td> <td>:b <span style="color: gray"><em>bufnum</em></span><br /> :bprev<br /> :bnext</td> <td>C-x b</td> <td>M-x switch-to-buffer<br /> M-x ido-switch-buffer</td> <td>M-<<br /> M-></td> </tr> <tr> <td><a name="diff-buffer-file" id="diff-buffer-file"></a><a href="text-mode-editors#diff-buffer-file-note">diff buffer and file</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:w !diff % -</td> <td></td> <td>M-x diff-buffer-with-file</td> <td></td> </tr> <tr> <td><a name="save-buffer" id="save-buffer"></a><a href="text-mode-editors#save-buffer-note">save buffer</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:w</td> <td>C-x C-s</td> <td>M-x save-buffer</td> <td>C-o ENTER</td> </tr> <tr> <td><a name="save-all-buffers" id="save-all-buffers"></a><a href="text-mode-editors#save-all-buffers-note">save all buffers</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:wa</td> <td>C-x s</td> <td>M-x save-some-buffer</td> <td></td> </tr> <tr> <td><a name="revert-buffer" id="revert-buffer"></a><a href="text-mode-editors#revert-buffer-note">revert buffer</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:e!</td> <td></td> <td>M-x revert-buffer</td> <td></td> </tr> <tr> <td><a name="write-buffer-to-different-file" id="write-buffer-to-different-file"></a><a href="text-mode-editors#write-buffer-to-different-file-note">write buffer to different file</a></td> <td>:w <span style="color: gray"><em>path</em></span></td> <td>C-x C-w</td> <td>M-x write-file<br /> M-x ido-write-file</td> <td>C-o <span style="color: gray"><em>path</em></span></td> </tr> <tr> <td><a name="write-region-to-file" id="write-region-to-file"></a><a href="text-mode-editors#write-region-to-file-note">write region to file</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:w <span style="color: gray"><em>path</em></span><br /> <span style="color: gray"><em>Don't remove the</em> '<,'> <em>vim inserts after the colon.</em></span></td> <td></td> <td>M-x write-region</td> <td></td> </tr> <tr> <td><a name="insert-file" id="insert-file"></a><a href="text-mode-editors#insert-file-note">insert file</a></td> <td>:r</td> <td>C-x i</td> <td>M-x insert-file<br /> M-x ido-insert-file</td> <td>C-r</td> </tr> <tr> <th colspan="5"><a name="minibuffer" id="minibuffer"></a><strong><a href="text-mode-editors#minibuffer-note">minibuffer</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>enter minibuffer</td> <td>:</td> <td><span style="color: gray"><em>use command which prompts for an argument</em></span></td> <td></td> <td></td> </tr> <tr> <td>move cursor<br /> <span style="color: gray"><em>left, right</em></span></td> <td>←<br /> →</td> <td></td> <td></td> <td></td> </tr> <tr> <td>delete previous char</td> <td>DEL</td> <td>DEL</td> <td></td> <td></td> </tr> <tr> <td>delete previous word</td> <td>C-w</td> <td>M-DEL</td> <td>backward-kill-word</td> <td></td> </tr> <tr> <td>go to beginning of command line</td> <td>C-b</td> <td>C-a</td> <td>move-beginning-of-line</td> <td></td> </tr> <tr> <td>go to end of command line</td> <td>C-e</td> <td>C-e</td> <td>move-end-of-line</td> <td></td> </tr> <tr> <td>clear buffer</td> <td>C-u</td> <td>C-a C-k</td> <td></td> <td></td> </tr> <tr> <td>cancel command</td> <td>ESC<br /> C-c</td> <td>C-g</td> <td>abort-recursive-edit</td> <td></td> </tr> <tr> <td>complete</td> <td>TAB</td> <td>TAB</td> <td>minibuffer-complete</td> <td></td> </tr> <tr> <td>display completions</td> <td>C-d</td> <td>?</td> <td>minibuffer-completion-help</td> <td></td> </tr> <tr> <td>select completions buffer</td> <td></td> <td>M-v</td> <td>switch-to-completions</td> <td></td> </tr> <tr> <td>show history</td> <td>:history</td> <td></td> <td></td> <td></td> </tr> <tr> <td>go back in history</td> <td></td> <td>M-p</td> <td>previous-history-element</td> <td></td> </tr> <tr> <td>go forward in history</td> <td></td> <td>M-n</td> <td>next-history-element</td> <td></td> </tr> <tr> <th colspan="5"><a name="ido" id="ido"></a><strong><a href="text-mode-editors#ido-note">ido</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>select first match</td> <td></td> <td>RET</td> <td>ido-exit-minibuffer</td> <td></td> </tr> <tr> <td>select input string</td> <td></td> <td>C-j</td> <td>ido-select-text</td> <td></td> </tr> <tr> <td>remove directory from input string</td> <td></td> <td>DEL</td> <td>ido-delete-backward-updir</td> <td></td> </tr> <tr> <td>put first match at end of list</td> <td></td> <td>C-s<br /> ←</td> <td>ido-prev-match</td> <td></td> </tr> <tr> <td>put last match at front of list</td> <td></td> <td>C-r<br /> →</td> <td>ido-next-match</td> <td></td> </tr> <tr> <td>cycle through work directory history<br /> <span style="color: gray"><em>next, previous</em></span></td> <td></td> <td>M-n<br /> M-p</td> <td>ido-next-work-directory<br /> ido-prev-work-directory</td> <td></td> </tr> <tr> <td>remove current directory from work directory history</td> <td></td> <td>M-k</td> <td>ido-forget-work-directory</td> <td></td> </tr> <tr> <td>goto root directory</td> <td></td> <td><span style="white-space: pre-wrap;">//</span></td> <td></td> <td></td> </tr> <tr> <td>goto home directory</td> <td></td> <td>~/</td> <td></td> <td></td> </tr> <tr> <td>toggle between substring and prefix matching</td> <td></td> <td>C-p</td> <td>ido-toggle-prefix</td> <td></td> </tr> <tr> <td>show matches in separate buffer</td> <td></td> <td>?</td> <td>ido-completion-help</td> <td></td> </tr> <tr> <td>fall back to switch-buffer</td> <td></td> <td>C-b</td> <td></td> <td></td> </tr> <tr> <td>fall back to find-file</td> <td></td> <td>C-f</td> <td></td> <td></td> </tr> <tr> <td>open in dired</td> <td></td> <td>C-d</td> <td></td> <td></td> </tr> <tr> <td>kill buffer or delete file</td> <td></td> <td>C-k</td> <td>ido-delete-file-at-head</td> <td></td> </tr> <tr> <td>create directory</td> <td></td> <td>M-m</td> <td>ido-make-directory</td> <td></td> </tr> <tr> <th colspan="5"><a name="history" id="history"></a><strong><a href="text-mode-editors#history-note">history</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="repeat" id="repeat"></a><a href="text-mode-editors#repeat-note">repeat</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>.</td> <td>C-x z</td> <td>M-x repeat</td> <td></td> </tr> <tr> <td><a name="undo" id="undo"></a><a href="text-mode-editors#undo-note">undo</a></td> <td>u</td> <td>C-/<br /> C-_<br /> C-x u</td> <td>M-x undo</td> <td><span style="color: gray"><em>none or</em></span> M-u <span style="color: gray"><em>when invoked with</em> <tt>-u</tt> <em>flag</em></span></td> </tr> <tr> <td><a name="redo" id="redo"></a><a href="text-mode-editors#redo-note">redo</a></td> <td>C-r</td> <td><span style="color: gray"><em>move cursor to break undo chain, then</em></span><br /> C-x u</td> <td></td> <td><span style="color: gray"><em>none or</em></span> M-e <span style="color: gray"><em>when invoked with</em> <tt>-u</tt> <em>flag</em></span></td> </tr> <tr> <td><a name="undo-last-cmd-not-undone" id="undo-last-cmd-not-undone"></a><a href="text-mode-editors#undo-last-cmd-not-undone-note">undo last command not undone</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td></td> <td>M-x undo-only</td> <td></td> </tr> <tr> <td><a name="goto-version" id="goto-version"></a><a href="text-mode-editors#goto-version-note">goto version</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:undo 10</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="goto-prev-version" id="goto-prev-version"></a><a href="text-mode-editors#goto-prev-version-note">goto previous version</a><br /> <span style="color: gray"><em>1 version ago, 5 versions ago</em></span></td> <td>g-<br /> 5g-</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="goto-next-version" id="goto-next-version"></a><a href="text-mode-editors#goto-next-version-note">goto next version</a><br /> <span style="color: gray"><em>1 version hence, 5 versions hence</em></span></td> <td>g+<br /> 5g+</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="go-back-in-time" id="go-back-in-time"></a><a href="text-mode-editors#go-back-in-time-note">go back in time</a><br /> <span style="color: gray"><em>seconds, minutes, days, hours</em></span></td> <td>:earlier 10s<br /> :earlier 10m<br /> :earlier 10h<br /> :earlier 10d</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="go-forward-in-time" id="go-forward-in-time"></a><a href="text-mode-editors#go-forward-in-time-note">go forward in time</a><br /> <span style="color: gray"><em>seconds, minutes, days, hours</em></span></td> <td>:later 10s<br /> :later 10m<br /> :later 10h<br /> :later 10d</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="goto-saved-version" id="goto-saved-version"></a><a href="text-mode-editors#goto-saved-version-note">goto saved version</a><br /> <span style="color: gray"><em>previous, next</em></span></td> <td>:earlier lf<br /> :later lf</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="keystroke-history" id="keystroke-history"></a><a href="text-mode-editors#keystroke-history-note">keystroke history</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td>C-h l</td> <td>M-x view-lossage</td> <td></td> </tr> <tr> <td><a name="undo-branches" id="undo-branches"></a><a href="text-mode-editors#undo-branches-note">undo branches</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>:undolist</td> <td></td> <td></td> <td></td> </tr> <tr> <th colspan="5"><a name="searching-replacing" id="searching-replacing"></a><strong><a href="text-mode-editors#searching-replacing-note">searching and replacing</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="search" id="search"></a><a href="text-mode-editors#search-note">search</a></td> <td>/</td> <td>C-s</td> <td>M-x isearch-forward</td> <td>C-w</td> </tr> <tr> <td><a name="repeat-last-search" id="repeat-last-search"></a><a href="text-mode-editors#repeat-last-search-note">repeat last search</a></td> <td>n</td> <td>C-s</td> <td></td> <td>M-w</td> </tr> <tr> <td><a name="repeat-last-search-backward" id="repeat-last-search-backward"></a><a href="text-mode-editors#repeat-last-search-backward-note">repeat last search backward</a></td> <td>N</td> <td>C-r</td> <td></td> <td></td> </tr> <tr> <td><a name="search-backwards" id="search-backwards"></a><a href="text-mode-editors#search-backwards-note">search backwards</a></td> <td>?</td> <td>C-r</td> <td>M-x isearch-backward</td> <td></td> </tr> <tr> <td><a name="next-char-on-line" id="next-char-on-line"></a><a href="text-mode-editors#next-char-on-line-note">next 'x' on line</a></td> <td>f x</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="prev-char-on-line" id="prev-char-on-line"></a><a href="text-mode-editors#prev-char-on-line-note">previous 'x' on line</a></td> <td>F x</td> <td></td> <td></td> <td></td> </tr> <tr> <td><a name="search-replace" id="search-replace"></a><a href="text-mode-editors#search-replace-note">search and replace</a></td> <td>:%s/<span style="color: gray"><em>pat</em></span>/<span style="color: gray"><em>repl</em></span>/g</td> <td></td> <td>M-x query-replace</td> <td>C-\<br /> M-r</td> </tr> <tr> <td><a name="recursive-edit" id="recursive-edit"></a><a href="text-mode-editors#recursive-edit-note">recursive edit during search and replace</a></td> <td></td> <td>C-r</td> <td></td> <td></td> </tr> <tr> <td><a name="exit-recursive-edit" id="exit-recursive-edit"></a><a href="text-mode-editors#exit-recursive-edit-note">exit recursive edit</a></td> <td></td> <td>C-M-c</td> <td>M-x exit-recursive-edit</td> <td></td> </tr> <tr> <td><a name="search-multiple-buffers" id="search-multiple-buffers"></a><a href="text-mode-editors#search-multiple-buffers-note">search multiple buffers</a></td> <td></td> <td></td> <td>M-x multi-occur</td> <td></td> </tr> <tr> <th colspan="5"><a name="sorting" id="sorting"></a><a name="counting" id="counting"></a><strong><a href="text-mode-editors#sorting-note">sorting and counting</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="sort" id="sort"></a><a href="text-mode-editors#sort-note">sort region</a></td> <td><span style="color: gray"><em>visual mode:</em></span><br /> !sort</td> <td></td> <td>M-x sort-lines</td> <td></td> </tr> <tr> <td><a name="numeric-sort" id="numeric-sort"></a><a href="text-mode-editors#numeric-sort-note">numeric sort</a></td> <td><span style="color: gray"><em>visual mode:</em></span><br /> !sort -n</td> <td></td> <td>M-x sort-numeric-fields</td> <td></td> </tr> <tr> <td><a name="sort-field" id="sort-field"></a><a href="text-mode-editors#sort-field-note">sort by 2nd field</a><br /> <span style="color: gray"><em>whitespace delimited</em></span></td> <td><span style="color: gray"><em>visual mode:</em></span><br /> !sort -k 2</td> <td></td> <td>C-u 2 M-x sort-fields</td> <td></td> </tr> <tr> <td><a name="sort-fixed-width" id="sort-fixed-width"></a><a href="text-mode-editors#sort-fixed-width-note">sort by fixed width column</a></td> <td></td> <td></td> <td><span style="color: gray"><em>place mark at start of field</em></span><br /> M-x sort-columns</td> <td></td> </tr> <tr> <td><a name="reverse" id="reverse"></a><a href="text-mode-editors#reverse-note">reverse</a></td> <td><span style="color: gray"><em>visual mode:</em></span><br /> !tac</td> <td></td> <td>M-x reverse-region</td> <td></td> </tr> <tr> <td><a name="count-lines-words-chars" id="count-lines-words-chars"></a><a href="text-mode-editors#count-lines-words-chars-note">count lines, words, and chars in document</a></td> <td>!wc %</td> <td></td> <td>M-x count-words</td> <td></td> </tr> <tr> <td><a name="count-regex" id="count-regex"></a><a href="text-mode-editors#count-regex-note">count regex matches in region</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td></td> <td>M-x count-matches</td> <td></td> </tr> <tr> <th colspan="5"><a name="case" id="case"></a><strong><a href="text-mode-editors#case-note">case</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="uppercase-word" id="uppercase-word"></a><a href="text-mode-editors#uppercase-word-note">uppercase word</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>gUw<br /> <br /> <span style="color: gray"><em>uppercase line:</em></span><br /> gUU</td> <td>M-u</td> <td>M-x upcase-word</td> <td></td> </tr> <tr> <td><a name="lowercase-word" id="lowercase-word"></a><a href="text-mode-editors#lowercase-word-note">lowercase word</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td>guw<br /> <br /> <span style="color: gray"><em>lowercase line:</em></span><br /> guu</td> <td>M-l</td> <td>M-x downcase-word</td> <td></td> </tr> <tr> <td><a name="capitalize-word" id="capitalize-word"></a><a href="text-mode-editors#capitalize-word-note">capitalize word</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td>M-c</td> <td>M-x capitalize-word</td> <td></td> </tr> <tr> <td><a name="uppercase-region" id="uppercase-region"></a><a href="text-mode-editors#uppercase-region-note">uppercase region</a></td> <td><span style="color: gray"><em>visual mode:</em></span><br /> gU</td> <td>C-x C-u</td> <td>M-x upcase-region</td> <td></td> </tr> <tr> <td><a name="lowercase-region" id="lowercase-region"></a><a href="text-mode-editors#lowercase-region-note">lowercase region</a></td> <td><span style="color: gray"><em>visual mode:</em></span><br /> gu</td> <td>C-x C-l</td> <td>M-x downcase-region</td> <td></td> </tr> <tr> <td><a name="title-case-region" id="title-case-region"></a><a href="text-mode-editors#title-case-region-note">title-case region</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td></td> <td>M-x capitalize-region</td> <td></td> </tr> <tr> <th colspan="5"><a name="indentation" id="indentation"></a><strong><a href="text-mode-editors#indentation-note">indentation and rectangles</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>insert tab at beginning of line</td> <td><span style="white-space: pre-wrap;">>></span></td> <td></td> <td></td> <td></td> </tr> <tr> <td>remove tab from beginning of line</td> <td><span style="white-space: pre-wrap;"><<</span></td> <td></td> <td></td> <td></td> </tr> <tr> <td>indent region</td> <td><span style="color: gray"><em>visual mode:</em></span><br /> <span style="white-space: pre-wrap;">></span></td> <td></td> <td></td> <td></td> </tr> <tr> <td>syntactically indent line</td> <td></td> <td><span style="color: gray"><em>but electric-indent default in 24.4:</em></span><br /> TAB</td> <td>M-x indent-for-tab-command</td> <td></td> </tr> <tr> <td>syntactically indent region</td> <td></td> <td></td> <td>M-x indent-region</td> <td></td> </tr> <tr> <td>replace tabs in region with spaces</td> <td></td> <td></td> <td>M-x untabify</td> <td></td> </tr> <tr> <td>fill paragraph</td> <td></td> <td>M-q</td> <td>M-x fill-paragraph</td> <td></td> </tr> <tr> <td>justify paragraph</td> <td></td> <td>C-u M-q</td> <td></td> </tr> <tr> <td>fill region</td> <td></td> <td></td> <td>M-x fill-region</td> <td></td> </tr> <tr> <td>remove all whitespace on left of region</td> <td></td> <td></td> <td>M-x delete-whitespace-rectangle</td> <td></td> </tr> <tr> <td>vertically align parts in region matching regexp</td> <td></td> <td></td> <td>M-x align-regexp</td> <td></td> </tr> <tr> <td>prepend string to each line of rectangle</td> <td></td> <td>C-x r t RET <span style="color: gray"><em>str</em></span></td> <td>M-x string-insert</td> <td></td> </tr> <tr> <td>replace each line of rectange with string</td> <td></td> <td></td> <td>M-x string-rectangle</td> <td></td> </tr> <tr> <td>insert blank rectangle</td> <td>C-v <span style="color: gray"><em>…</em></span> I <span style="color: gray"><em>…</em></span> ESC</td> <td>C-x r o</td> <td>M-x open-rectangle</td> <td></td> </tr> <tr> <td>delete rectangle</td> <td>C-v <span style="color: gray"><em>…</em></span> d</td> <td>C-x r k</td> <td>M-x kill-rectangle</td> <td></td> </tr> <tr> <td>paste rectangle</td> <td></td> <td>C-x r y</td> <td>M-x yank-rectangle</td> <td></td> </tr> <tr> <td>clear rectangle</td> <td></td> <td>C-x r c</td> <td>M-x clear-rectangle</td> <td></td> </tr> <tr> <th colspan="5"><a name="spelling" id="spelling"></a><strong><a href="text-mode-editors#spelling-note">spelling</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>spellcheck buffer</td> <td></td> <td></td> <td>M-x ispell</td> <td>C-t</td> </tr> <tr> <td>spellcheck mode</td> <td>:setlocal spell spelllang=en_us</td> <td></td> <td>M-x flyspell-mode</td> <td></td> </tr> <tr> <th colspan="5"><a name="panes" id="panes"></a><strong><a href="text-mode-editors#panes-note">panes</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>vertical split</td> <td>:sp <span style="color: gray"><em>path</em></span></td> <td>C-x 2</td> <td>M-x split-window-vertically</td> <td></td> </tr> <tr> <td>horizontal split</td> <td>:vsp <span style="color: gray"><em>path</em></span></td> <td>C-x 3</td> <td>M-x split-window-right</td> <td></td> </tr> <tr> <td>close other panes</td> <td></td> <td>C-x 1</td> <td>M-x delete-other-windows</td> <td></td> </tr> <tr> <td>close current pane</td> <td>:q</td> <td>C-x 0</td> <td>M-x delete-window</td> <td></td> </tr> <tr> <td>move to next pane</td> <td>C-w h, C-w ←<br /> C-w l, C-w →<br /> C-w j, C-w ↑<br /> C-w k, C-w ↓</td> <td>C-x o<br /> C-x O</td> <td>M-x other-window<br /> C-u -1 M-x other-window</td> <td></td> </tr> <tr> <td>widen pane</td> <td></td> <td>C-x {<br /> C-x }</td> <td>M-x enlarge-window-horizontally</td> <td></td> </tr> <tr> <td>narrow pane</td> <td></td> <td>C-x {<br /> C-x }</td> <td>M-x shrink-window-horizontally</td> <td></td> </tr> <tr> <td>make pane taller</td> <td>C-w +</td> <td></td> <td>M-x enlarge-window</td> <td></td> </tr> <tr> <td>make pane shorter</td> <td>C-w -</td> <td></td> <td></td> <td></td> </tr> <tr> <td>rotate panes</td> <td>C-w r</td> <td></td> <td></td> <td></td> </tr> <tr> <td>balance panes</td> <td></td> <td>C-x +</td> <td>M-x balance-windows</td> <td></td> </tr> <tr> <th colspan="5"><a name="macros" id="macros"></a><a href="text-mode-editors#macros-note">macros</a></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>start recording macro</td> <td>q <span style="color: gray"><em>letter</em></span></td> <td>C-x (</td> <td>M-x kmacro-start-macro</td> <td></td> </tr> <tr> <td>end recording macro</td> <td>q</td> <td>C-x )</td> <td>M-x kmacro-end-macro</td> <td></td> </tr> <tr> <td>run macro</td> <td>@ <span style="color: gray"><em>letter</em></span></td> <td>C-x e</td> <td>M-x kmacro-end-and-call-macro</td> <td></td> </tr> <tr> <td>run macro on each line in region</td> <td></td> <td>C-x C-k r</td> <td>M-x apply-macro-to-region-lines</td> <td></td> </tr> <tr> <td>insert counter</td> <td></td> <td>C-x C-k C-i</td> <td>M-x kmacro-insert-counter</td> <td></td> </tr> <tr> <td>set counter</td> <td></td> <td>C-x C-k C-c</td> <td>M-x kmacro-set-counter</td> <td></td> </tr> <tr> <td>set counter format</td> <td></td> <td><span style="color: gray"><em>uses printf-style format specifiers:</em></span><br /> C-x C-k C-f</td> <td>M-x kmacro-set-format</td> <td></td> </tr> <tr> <td>query user to continue</td> <td></td> <td><span style="color: gray"><em>user can respond with: y n q</em></span><br /> C-x q</td> <td></td> <td></td> </tr> <tr> <td>put user in recursive edit</td> <td></td> <td>C-u C-x q</td> <td></td> <td></td> </tr> <tr> <th colspan="5"><a name="ascii-art" id="ascii-art"></a><strong><a href="text-mode-editors#ascii-art-note">ascii art</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>ascii art mode</td> <td></td> <td></td> <td>M-x picture-mode</td> <td></td> </tr> <tr> <td>return to original mode</td> <td></td> <td>C-c C-c</td> <td>M-c picture-mode-exit</td> <td></td> </tr> <tr> <td>up</td> <td></td> <td>C-p</td> <td><span style="color: gray"><em>available in all modes; bound to C-p only in picture-mode:</em></span><br /> M-x picture-move-up</td> <td></td> </tr> <tr> <td>down</td> <td></td> <td>C-n</td> <td>M-x picture-move-down</td> <td></td> </tr> <tr> <td>left</td> <td></td> <td>C-b</td> <td>M-x picture-forward-column</td> <td></td> </tr> <tr> <td>right</td> <td></td> <td>C-f</td> <td>M-x picture-backward-column</td> <td></td> </tr> <tr> <td>beginning of line</td> <td></td> <td>C-a</td> <td>M-x picture-beginning-of-line</td> <td></td> </tr> <tr> <td>beginning of next line</td> <td></td> <td>RET</td> <td>M-x picture-newline</td> <td></td> </tr> <tr> <td>move to next non-blank on current line</td> <td></td> <td>C-u M-TAB</td> <td>C-u M-x picture-tab-search</td> <td></td> </tr> <tr> <td>move under next non-blank on previous line</td> <td></td> <td>M-TAB</td> <td>M-x picture-tab-search</td> <td></td> </tr> <tr> <td>set movement to left after insert</td> <td></td> <td>C-c <</td> <td>M-x picture-movement-left</td> <td></td> </tr> <tr> <td>set movement to right after insert</td> <td></td> <td>C-c ></td> <td>M-x picture-movement-right</td> <td></td> </tr> <tr> <td>set movement to up after insert</td> <td></td> <td>C-c ^</td> <td>M-x picture-movement-up</td> <td></td> </tr> <tr> <td>set movement to down after insert</td> <td></td> <td>C-c .</td> <td>M-x picture-movement-down</td> <td></td> </tr> <tr> <td>set movement to up and left after insert</td> <td></td> <td>C-c <span style="white-space: pre-wrap;">`</span></td> <td>M-x picture-movement-nw</td> <td></td> </tr> <tr> <td>set movement to up and right after insert</td> <td></td> <td>C-c '</td> <td>M-x picture-movement-ne</td> <td></td> </tr> <tr> <td>set movement to down and left after insert</td> <td></td> <td>C-c /</td> <td>M-x picture-movement-sw</td> <td></td> </tr> <tr> <td>set movement to down and right after insert</td> <td></td> <td>C-c \</td> <td>M-x picture-movement-se</td> <td></td> </tr> <tr> <td>move in direction of movement</td> <td></td> <td>C-c C-f</td> <td>M-x picture-motion</td> <td></td> </tr> <tr> <td>move opposite direction of movement</td> <td></td> <td>C-c C-b</td> <td>M-x picture-motion-reverse</td> <td></td> </tr> <tr> <td>last nonblank on line</td> <td></td> <td>C-e</td> <td>M-x picture-end-of-line</td> <td></td> </tr> <tr> <td>insert blank line</td> <td></td> <td>C-o</td> <td>M-x picture-open-line</td> <td></td> </tr> <tr> <td>duplicate line</td> <td></td> <td>C-j</td> <td>M-x picture-duplicate-line</td> <td></td> </tr> <tr> <td>replace with space</td> <td></td> <td>SPC<br /> C-d</td> <td>M-x picture-clear-column</td> <td></td> </tr> <tr> <td>move left and replace with space</td> <td></td> <td>DEL</td> <td>M-x picture-backward-clear-column</td> <td></td> </tr> <tr> <td>delete char</td> <td></td> <td>C-c C-d</td> <td>M-x picture-delete-char</td> <td></td> </tr> <tr> <td>delete to end of line</td> <td></td> <td>C-k</td> <td>M-k picture-clear-line</td> <td></td> </tr> <tr> <th colspan="5"><a name="org" id="org"></a><strong><a href="text-mode-editors#org-note">org</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td></td> <td></td> <th colspan="2">outlines</th> <td></td> </tr> <tr> <td>cycle list item visibility<br /> <br /> <span style="color: gray"><em>folded, children, descendants</em></span></td> <td></td> <td>TAB</td> <td>M-x org-cycle</td> <td></td> </tr> <tr> <td>cycle buffer outline visibility<br /> <br /> <span style="color: gray"><em>overview, contents, all</em></span></td> <td></td> <td>C-u TAB</td> <td>M-x org-global-cycle</td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">tables</th> <td></td> </tr> <tr> <td>create table</td> <td></td> <td>C-c <span style="white-space: pre-wrap;">|</span></td> <td>M-x org-table-create-or-convert-from-region</td> <td></td> </tr> <tr> <td>align table columns</td> <td></td> <td>C-c C-c</td> <td>M-x org-table-align</td> <td></td> </tr> <tr> <td>move column at point right</td> <td></td> <td>M-→</td> <td>M-x org-table-move-column-right</td> <td></td> </tr> <tr> <td>move column at point left</td> <td></td> <td>M-←</td> <td>M-x org-table-move-column-left</td> <td></td> </tr> <tr> <td>insert row above point</td> <td></td> <td></td> <td>M-x org-table-insert-row</td> <td></td> </tr> <tr> <td>insert column left of point</td> <td></td> <td></td> <td>M-x org-table-insert-column</td> <td></td> </tr> <tr> <td>insert horizontal line under point</td> <td></td> <td>C-c -</td> <td>M-x org-table-insert-hline</td> <td></td> </tr> <tr> <td>delete column at point</td> <td></td> <td></td> <td>M-x org-table-delete-column</td> <td></td> </tr> <tr> <td>sort table by column at point</td> <td></td> <td>C-c ^</td> <td>M-x org-sort</td> <td></td> </tr> <tr> <td>import tab delimited file</td> <td></td> <td></td> <td>M-x org-table-import</td> <td></td> </tr> <tr> <td>export tab delimited file</td> <td></td> <td></td> <td>M-x org-table-export</td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">hyperlinks</th> <td></td> </tr> <tr> <td>visit link</td> <td></td> <td>C-c C-o<br /> RET</td> <td>M-x org-open-at-point</td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">export</th> <td></td> </tr> <tr> <td>export as html</td> <td></td> <td>C-c C-e h h</td> <td>M-x org-export-dispatch h h</td> <td></td> </tr> <tr> <th colspan="5"><a name="intl" id="intl"></a><strong><a href="text-mode-editors#intl-note">input methods and encodings</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="insert-unicode" id="insert-unicode"></a><a href="text-mode-editors#insert-unicode-note">insert unicode character</a></td> <td>C-v u 221e</td> <td>C-x 8 RET infinity<br /> C-x 8 RET 221e</td> <td>M-x ucs-insert</td> <td></td> </tr> <tr> <td><a name="set-input-method" id="set-input-method"></a><a href="text-mode-editors#set-input-method-note">set input method</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td>C-x RET C-\</td> <td>M-x set-input-method</td> <td></td> </tr> <tr> <td><a name="list-input-methods" id="list-input-methods"></a><a href="text-mode-editors#list-input-methods-note">list input methods</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td></td> <td>M-x list-input-methods</td> <td></td> </tr> <tr> <td><a name="toggle-input-method" id="toggle-input-method"></a><a href="text-mode-editors#toggle-input-method-note">enable/disable input method</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td>C-\</td> <td>M-x toggle-input-method</td> <td></td> </tr> <tr> <td><a name="describe-input-method" id="describe-input-method"></a><a href="text-mode-editors#describe-input-method-note">describe input method</a><br /> <span style="white-space: pre-wrap;"> </span></td> <td></td> <td>C-h I</td> <td>M-x describe-input-method</td> <td></td> </tr> <tr> <td><a name="show-key" id="show-key"></a><a href="text-mode-editors#show-key-note">how to type character at point</a></td> <td></td> <td></td> <td>M-x quail-show-key</td> <td></td> </tr> <tr> <td><a name="set-file-encoding" id="set-file-encoding"></a><a href="text-mode-editors#set-file-encoding-note">set file encoding</a></td> <td>:w ++enc=utf-8 <span style="color: gray"><em>foo</em></span>.txt</td> <td>C-x RET f</td> <td>M-x set-buffer-file-coding-system</td> <td></td> </tr> <tr> <td><a name="set-eol" id="set-eol"></a><a href="text-mode-editors#set-eol-note">set end of line character</a></td> <td></td> <td></td> <td>M-x set-buffer-file-coding-system RET utf-8-unix<br /> M-x set-buffer-file-coding-system RET utf-8-dos<br /> M-x set-buffer-file-coding-system RET utf-8-mac</td> <td></td> </tr> <tr> <td><a name="show-file-encoding" id="show-file-encoding"></a><a href="text-mode-editors#show-file-encoding-note">show file encoding</a></td> <td></td> <td></td> <td>M-: buffer-file-coding-system</td> <td></td> </tr> <tr> <td><a name="list-encodings" id="list-encodings"></a><a href="text-mode-editors#lilst-encodings-note">list available encodings</a></td> <td>:h encoding-values</td> <td></td> <td>M-x list-coding-systems</td> <td></td> </tr> <tr> <th colspan="5"><a name="help" id="help"></a><strong><a href="text-mode-editors#help-note">help</a></strong></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>help <em>(q to exit help mode)</em></td> <td>:help</td> <td>C-h i</td> <td>M-x info</td> <td>C-g</td> </tr> <tr> <td>summarize help commands</td> <td></td> <td>C-h ?</td> <td>M-x help-for-help</td> <td></td> </tr> <tr> <td>tutorial</td> <td>:!vimtutor</td> <td>C-h t</td> <td>M-x help-with-tutorial</td> <td></td> </tr> <tr> <td>list key bindings</td> <td></td> <td>C-h b</td> <td>M-x describe-bindings</td> <td></td> </tr> <tr> <td>describe mode</td> <td></td> <td>C-h m</td> <td>M-x describe-mode</td> <td></td> </tr> <tr> <td><a name="show-key-binding" id="show-key-binding"></a><a href="text-mode-editors#show-key-binding-note">show key binding</a></td> <td>:help <span style="color: gray"><em>key</em></span></td> <td>C-h c<br /> C-h k</td> <td>M-x describe-key-briefly<br /> M-x describe-key</td> <td></td> </tr> <tr> <td>function documentation</td> <td>:help :<span style="color: gray"><em>func</em></span><br /> :help <span style="color: gray"><em>key</em></span></td> <td>C-h f</td> <td>M-x describe-function</td> <td></td> </tr> <tr> <td>variable documentation</td> <td>:help '<span style="color: gray"><em>var</em></span>'</td> <td>C-h v</td> <td>M-x describe-variable</td> <td></td> </tr> <tr> <td>apropos</td> <td></td> <td>C-h a</td> <td>M-x apropos-command<br /> <br /> <span style="color: gray"><em>also variables, properties, functions, and macros:</em></span><br /> M-x apropos</td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">info-mode</th> <td></td> </tr> <tr> <td>visit help link</td> <td>C-]</td> <td>RET</td> <td>M-x Info-follow-nearest-node</td> <td></td> </tr> <tr> <td>help link style</td> <td style="text-align: center;"><span style="color: gray"><span style="white-space: pre-wrap;">|</span>braced by pipe chars<span style="white-space: pre-wrap;">|</span></span></td> <td colspan="2" style="text-align: center;"><span style="color: mediumblue"><span style="text-decoration: underline;">underlined and blue</span></span></td> <td></td> </tr> <tr> <td>go back a help link, forward a help link</td> <td>C-o<br /> <span style="color: gray"><em>none</em></span></td> <td>l<br /> r</td> <td>M-x Info-history-back<br /> M-x Info-history-forward</td> <td></td> </tr> <tr> <td>navigate info page hierarchy</td> <td></td> <td>n<br /> p<br /> u</td> <td>M-x Info-next<br /> M-x Info-prev<br /> M-x Info-up</td> <td></td> </tr> <tr> <td>man page</td> <td>:!man ls</td> <td></td> <td>M-x man RET ls</td> <td></td> </tr> <tr> <th colspan="5"><a name="browse-files" id="browse-files"></a><a href="text-mode-editors#browse-files-note">browse files</a></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>display directory in buffer</td> <td>:e <span style="color: gray"><em>dirpath</em></span></td> <td></td> <td>M-x dired</td> <td>C-r C-t</td> </tr> <tr> <td>search for files recursively by name</td> <td></td> <td></td> <td>M-x find-name-dired</td> <td></td> </tr> <tr> <td>search for files recursively by contents</td> <td></td> <td></td> <td>M-x find-grep-dired</td> <td></td> </tr> <tr> <td>search for files recursively by contents using ag -Q</td> <td></td> <td></td> <td><span style="color: gray"><em>install ag and ag.el:</em></span><br /> M-x ag-dired<br /> M-x ag-project-direct</td> <td></td> </tr> <tr> <td>search for files recursively by contents using ag</td> <td></td> <td></td> <td>M-x ag-dired-regexp<br /> M-x ag-project-direct-regexp</td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">dired-mode</th> <td></td> </tr> <tr> <td>delete</td> <td>D</td> <td></td> <td></td> <td></td> </tr> <tr> <td>flag for deletion</td> <td></td> <td>d</td> <td>M-x dired-flag-file-deletion</td> <td></td> </tr> <tr> <td>mark</td> <td></td> <td>m</td> <td>M-x dired-mark</td> <td></td> </tr> <tr> <td>mark by regex</td> <td></td> <td>% m</td> <td>M-x dired-mark-files-regexp</td> <td></td> </tr> <tr> <td>unflag or unmark</td> <td></td> <td>u</td> <td>M-x dired-unmark</td> <td></td> </tr> <tr> <td>unflag or unmark all</td> <td></td> <td>U</td> <td>M-x dired-unmark-all-marks</td> <td></td> </tr> <tr> <td>delete flagged files</td> <td></td> <td>x</td> <td>M-x dired-do-flagged-delete</td> <td></td> </tr> <tr> <td>mark autosave files for deletion</td> <td></td> <td>#</td> <td>M-x dired-flag-auto-save-files</td> <td></td> </tr> <tr> <td>mark twiddle files for deletion</td> <td></td> <td><span style="white-space: pre-wrap;">~</span></td> <td>M-x dired-flag-backup-files</td> <td></td> </tr> <tr> <td>visit file</td> <td>RET</td> <td>RET <span style="color: gray"><em>or</em></span> f</td> <td>M-x dired-find-file</td> <td>RET <span style="color: gray"><em>or</em></span> s</td> </tr> <tr> <td>visit file in other window</td> <td></td> <td>o</td> <td>M-x dired-find-file-other-window</td> <td></td> </tr> <tr> <td>visit parent directory</td> <td></td> <td>^</td> <td>M-x dired-up-directory</td> <td></td> </tr> <tr> <td>create new file</td> <td></td> <td>M-! touch <span style="color: gray"><em>path</em></span></td> <td></td> <td></td> </tr> <tr> <td>create new directory</td> <td></td> <td>+</td> <td>M-x dired-create-directory</td> <td></td> </tr> <tr> <td>shell command <span style="color: gray"><em>passes file under point as argument</em></span></td> <td></td> <td>!</td> <td>M-x dired-do-shell-argument</td> <td></td> </tr> <tr> <td>show subdirectory</td> <td></td> <td>i</td> <td>M-x dired-maybe-insert-subdir</td> <td></td> </tr> <tr> <td>hide subdirectory</td> <td></td> <td>$</td> <td>M-x dired-hide-subdir</td> <td></td> </tr> <tr> <td>hide all subdirectories</td> <td></td> <td>M-$</td> <td>M-x dired-hide-all</td> <td></td> </tr> <tr> <td>toggle sort order<br /> <span style="color: gray"><em>filename or last modification time</em></span></td> <td>s</td> <td>s</td> <td>M-x dired-sort-toggle-or-edit</td> <td></td> </tr> <tr> <th colspan="5"><a name="shell" id="shell"></a><a href="text-mode-editors#shell-note">shell</a></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td><a name="shell-buffer" id="shell-buffer"></a><a href="text-mode-editors#shell-buffer-note">open shell buffer</a></td> <td>:!sh</td> <td></td> <td>M-x shell<br /> <span style="color: gray"><em>install multi-term:</em></span><br /> M-x multi-term</td> <td></td> </tr> <tr> <td><a name="emulate-shell" id="emulate-shell"></a><a href="text-mode-editors#emulate-shell-note">emulate a shell</a></td> <td></td> <td></td> <td>M-x eshell</td> <td></td> </tr> <tr> <td><a name="shell-cmd" id="shell-cmd"></a><a href="text-mode-editors#shell-cmd-note">execute shell command</a></td> <td>:!<span style="color: gray"><em>cmd</em></span> <span style="color: gray"><em>args …</em></span></td> <td>M-!</td> <td>M-x shell-command</td> <td></td> </tr> <tr> <td><a name="region-to-shell-cmd" id="region-to-shell-cmd"></a><a href="text-mode-editors#region-to-shell-cmd-note">send region to shell command</a></td> <td></td> <td>M-|</td> <td>M-x shell-command-on-region</td> <td></td> </tr> <tr> <td><a name="doc-to-shell-cmd" id="doc-to-shell-cmd"></a><a href="text-mode-editors#doc-to-shell-cmd-note">send document to shell command</a></td> <td>!<span style="color: gray"><em>cmd</em></span> %</td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">shell-mode</th> <td></td> </tr> <tr> <td>recall prev cmd in history</td> <td></td> <td>M-p</td> <td>M-x comint-previous-input</td> <td></td> </tr> <tr> <td>recell next cmd in history</td> <td></td> <td>M-n</td> <td>M-x comint-next-input</td> <td></td> </tr> <tr> <th colspan="5"><a name="grep" id="grep"></a><a href="text-mode-editors#grep-note">grep</a></th> </tr> <tr> <th></th> <th></th> <th>emacs</th> <th>emacs</th> <th></th> </tr> <tr> <td>grep</td> <td>:grep <span style="color: gray"><em>pattern</em></span> *<br /> :cw</td> <td></td> <td>M-x grep</td> <td></td> </tr> <tr> <td>grep directories recursively</td> <td>:grep -r <span style="color: gray"><em>pattern</em></span> .<br /> :cw</td> <td></td> <td>M-x find-grep</td> <td></td> </tr> <tr> <td>stop grep</td> <td>C-c</td> <td></td> <td>M-x kill-grep</td> <td></td> </tr> <tr> <td>grep buffer</td> <td></td> <td></td> <td>M-x occur</td> <td></td> </tr> <tr> <td>ag -Q</td> <td><span style="color: gray"><em>install ag and ag.vim:</em></span><br /> :Ag -Q <span style="color: gray"><em>pattern</em></span></td> <td></td> <td><span style="color: gray"><em>install ag and ag-mode:</em></span><br /> M-x ag<br /> M-x ag-project</td> <td></td> </tr> <tr> <td>ag -Q -G</td> <td></td> <td></td> <td>M-x ag-files<br /> M-x ag-project-files</td> <td></td> </tr> <tr> <td>ag</td> <td>:Ag <span style="color: gray"><em>pattern</em></span></td> <td></td> <td>M-x ag-regexp<br /> M-x ag-project-regexp</td> <td></td> </tr> <tr> <td>close all ag-mode buffers</td> <td></td> <td></td> <td>M-x ag-kill-buffers</td> <td></td> </tr> <tr> <td>close other ag-mode buffers</td> <td></td> <td></td> <td>M-x ag-kill-other-buffers</td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">grep-mode</th> <td></td> </tr> <tr> <td>next match in source</td> <td>:cn</td> <td>n</td> <td>M-x next-error-no-select</td> <td></td> </tr> <tr> <td>prev match in source</td> <td>:cp</td> <td>p</td> <td>M-x previous-error-no-select</td> <td></td> </tr> <tr> <td>next match in output not in current file</td> <td>:cnf</td> <td>M-}</td> <td>M-x compilation-next-file</td> <td></td> </tr> <tr> <td>prev match in output not in current file</td> <td>:cpf</td> <td>M-{</td> <td>M-x compilation-previous-file</td> <td></td> </tr> <tr> <td>goto match in source</td> <td></td> <td>C-c C-c<br /> RET</td> <td>M-x compile-goto-error</td> <td></td> </tr> <tr> <td>stop grep</td> <td></td> <td>C-c C-k</td> <td>M-x kill-compilation</td> <td></td> </tr> <tr> <td>re-run grep</td> <td></td> <td>g</td> <td>M-x recompile</td> <td></td> </tr> <tr> <td>quit grep mode</td> <td>:ccl</td> <td>q</td> <td>M-x quit-window</td> <td></td> </tr> <tr> <th colspan="5"><a name="tags" id="tags"></a><a href="text-mode-editors#tags-note">tags</a></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>create tags file</td> <td></td> <td></td> <td>M-! find . -name '*.c' | etags</td> <td></td> </tr> <tr> <td>load tags file</td> <td></td> <td></td> <td>M-x visit-tags-table</td> <td></td> </tr> <tr> <td>goto tag</td> <td>:tag <span style="color: gray"><em>name</em></span></td> <td>M-.</td> <td>M-x find-tag</td> <td></td> </tr> <tr> <td>goto tag at point</td> <td>C-]</td> <td></td> <td></td> <td></td> </tr> <tr> <td>open tag in other window</td> <td></td> <td>C-x 4 .</td> <td>M-x find-tag-other-window</td> <td></td> </tr> <tr> <td>pop tag stack</td> <td>C-o<br /> :pop</td> <td>M-*</td> <td>M-x pop-tag-mark</td> <td></td> </tr> <tr> <td>show tag stack</td> <td>:tags</td> <td></td> <td></td> <td></td> </tr> <tr> <td>show tag signature</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>tag search</td> <td></td> <td></td> <td>M-x tags-search<br /> <br /> <span style="color: gray">M-, to go to next occurrence</span></td> <td></td> </tr> <tr> <th colspan="5"><a name="diff" id="diff"></a><a href="text-mode-editors#diff-note">diff</a></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th>nano</th> </tr> <tr> <td>diff two files</td> <td>$ vimdiff <span style="color: gray"><em>file file</em></span></td> <td></td> <td>M-x ediff</td> <td></td> </tr> <tr> <td>diff three files</td> <td>$ vimdiff <span style="color: gray"><em>file file file</em></span></td> <td></td> <td>M-x ediff3</td> <td></td> </tr> <tr> <td>switch to other window</td> <td>C-W w</td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">ediff-mode</th> <td></td> </tr> <tr> <td>apply hunk</td> <td>do</td> <td>a</td> <td></td> <td></td> </tr> <tr> <td>apply hunk in reverse</td> <td>dp</td> <td>b</td> <td></td> <td></td> </tr> <tr> <td>next hunk</td> <td>]c</td> <td>n</td> <td></td> <td></td> </tr> <tr> <td>previous hunk</td> <td>[c</td> <td>p</td> <td></td> <td></td> </tr> <tr> <td>save first file</td> <td></td> <td>wa</td> <td></td> <td></td> </tr> <tr> <td>save second file</td> <td></td> <td>wb</td> <td></td> <td></td> </tr> <tr> <td>save diff</td> <td></td> <td>wd</td> <td></td> <td></td> </tr> <tr> <th colspan="5"><a name="git" id="git"></a><a href="text-mode-editors#git-note">git</a></th> </tr> <tr> <th></th> <th></th> <th>emacs</th> <th>emacs</th> <th></th> </tr> <tr> <td>diff buffer with version control</td> <td></td> <td>C-x v =</td> <td>M-x vc-diff</td> <td></td> </tr> <tr> <td>revert buffer using version control</td> <td></td> <td>C-x v u</td> <td>M-x vc-revert</td> <td></td> </tr> <tr> <td>git blame on buffer</td> <td><span style="color: gray"><em>install vim-fugitive</em></span><br /> :Gblame</td> <td>C-x v g</td> <td>M-x vc-annotate</td> <td></td> </tr> <tr> <td>git status; use working directory</td> <td><span style="color: gray"><em>install vim-fugitive</em></span><br /> :Gstatus</td> <td></td> <td><span style="color: gray"><em>install magit</em></span><br /> M-x magit-status</td> <td></td> </tr> <tr> <td>git status; prompt for project path</td> <td></td> <td></td> <td>C-u M-x magit-status</td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">magit-mode</th> <td></td> </tr> <tr> <td>refresh status</td> <td></td> <td>g</td> <td>M-x magit-refresh</td> <td></td> </tr> <tr> <td>stage</td> <td></td> <td>s</td> <td>M-x magit-stage-item</td> <td></td> </tr> <tr> <td>unstage</td> <td></td> <td>u</td> <td>M-x magit-unstage-item</td> <td></td> </tr> <tr> <td>commit</td> <td></td> <td>c</td> <td>M-x magit-key-mode-popup-committing</td> <td></td> </tr> <tr> <td>push</td> <td></td> <td>P</td> <td>M-x magit-key-mode-popup-pushing</td> <td></td> </tr> <tr> <td>add file to .gitignore</td> <td></td> <td>i</td> <td>M-x magit-ignore-item</td> <td></td> </tr> <tr> <td>show commit history</td> <td></td> <td>l</td> <td>M-x magit-key-mode-popup-logging</td> <td></td> </tr> <tr> <td>show git process output</td> <td></td> <td>$</td> <td>M-x magit-display-process</td> <td></td> </tr> <tr> <td>close status buffer</td> <td></td> <td>q</td> <td>M-x magit-mode-quit-window</td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">magit-commit-mode</th> <td></td> </tr> <tr> <td>submit commit</td> <td></td> <td>C-c C-c</td> <td>M-x git-commit-commit</td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">magit-log-mode</th> <td></td> </tr> <tr> <th colspan="5"><a name="compile" id="compile"></a><a href="text-mode-editors#compile-note">compile</a></th> </tr> <tr> <th></th> <th></th> <th>emacs</th> <th>emacs</th> <th></th> </tr> <tr> <td>compile</td> <td>:make</td> <td></td> <td>M-x compile</td> <td></td> </tr> <tr> <td>stop compilation</td> <td></td> <td></td> <td>M-x kill-compilation</td> <td></td> </tr> <tr> <td></td> <td></td> <th colspan="2">compilation-mode</th> <td></td> </tr> <tr> <td>recompile</td> <td></td> <td>g</td> <td>M-x recompile</td> <td></td> </tr> <tr> <td>next error in output</td> <td></td> <td>M-n</td> <td></td> <td></td> </tr> <tr> <td>prev error in output</td> <td></td> <td>M-p</td> <td></td> <td></td> </tr> <tr> <td>next error in different source file</td> <td></td> <td>M-}</td> <td></td> <td></td> </tr> <tr> <td>prev error in different source file</td> <td></td> <td>M-{</td> <td></td> <td></td> </tr> <tr> <th colspan="5"><a name="debug" id="debug"></a><a href="text-mode-editors#debug-note">debug</a></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th></th> </tr> <tr> <td>start gdb</td> <td></td> <td></td> <td>M-x gdb</td> <td></td> </tr> <tr> <td>start jdb</td> <td></td> <td></td> <td>M-x jdb</td> <td></td> </tr> <tr> <td>set breakpoint</td> <td></td> <td>C-x SPC</td> <td>M-x gud-break</td> <td></td> </tr> <tr> <td>send ^C to debugger</td> <td></td> <td>C-c C-c</td> <td>M-x comint-interrupt-subjob</td> <td></td> </tr> <tr> <th colspan="5"><a name="lisp-interaction" id="lisp-interaction"></a><a href="text-mode-editors#lisp-interaction-note">lisp interaction</a></th> </tr> <tr> <th></th> <th></th> <th>emacs</th> <th>emacs</th> <th></th> </tr> <tr> <td>evaluate in minibuffer</td> <td></td> <td>M-:</td> <td>M-x eval-expression</td> <td></td> </tr> <tr> <td>evaluate sexp and insert result after point</td> <td></td> <td>C-j</td> <td>M-x eval-print-last-sexp</td> <td></td> </tr> <tr> <td>evaluate sexp and echo result in minibuffer</td> <td></td> <td>C-x C-e</td> <td>M-x eval-last-sexp</td> <td></td> </tr> <tr> <td>evaluate region</td> <td></td> <td></td> <td>M-x eval-region</td> <td></td> </tr> <tr> <td>eval buffer</td> <td></td> <td></td> <td>M-x eval-buffer</td> <td></td> </tr> <tr> <td>lisp REPL</td> <td></td> <td></td> <td>M-x ielm</td> <td></td> </tr> <tr> <th colspan="5"><a name="syntax-highlighting" id="syntax-highlighting"></a><a href="text-mode-editors#syntax-highlighting-note">syntax highlighting</a></th> </tr> <tr> <th></th> <th>vim</th> <th>emacs</th> <th>emacs</th> <th></th> </tr> <tr> <td>turn on</td> <td>:syntax enable</td> <td></td> <td>M-x font-lock-mode</td> <td></td> </tr> <tr> <td>turn off</td> <td>:syntax of</td> <td></td> <td>M-x font-lock-mode</td> <td></td> </tr> <tr> <td>show mode</td> <td>:setlocal syntax?</td> <td>C-h m</td> <td>M-x describe-mode</td> <td></td> </tr> <tr> <td>face at point</td> <td></td> <td>C-u C-x =</td> <td>M-x describe-face RET</td> <td></td> </tr> <tr> <td>customize face</td> <td>:hi Comment ctermfg=darkgray</td> <td></td> <td>M-x customize-face</td> <td></td> </tr> <tr> <td>list faces</td> <td>:help group-name</td> <td></td> <td>M-x list-faces-display</td> <td></td> </tr> <tr> <td>list colors</td> <td>:runtime syntax/colortest.vim</td> <td></td> <td>M-x list-colors-display</td> <td></td> </tr> <tr> <th><span style="color: #efefef"><span style="white-space: pre-wrap;">____________________________</span></span></th> <th><span style="color: #efefef"><span style="white-space: pre-wrap;">_________________________________</span></span></th> <th><span style="color: #efefef"><span style="white-space: pre-wrap;">_________________________________</span></span></th> <th><span style="color: #efefef"><span style="white-space: pre-wrap;">__________________________________________________</span></span></th> <th><span style="color: #efefef"><span style="white-space: pre-wrap;">_________________________________</span></span></th> </tr> </table> <p><a name="startup-note" id="startup-note"></a></p> <h1 id="toc0"><span><a href="text-mode-editors#startup">Startup</a></span></h1> <p><a name="launch-note" id="launch-note"></a></p> <h2 id="toc1"><span><a href="text-mode-editors#launch">launch</a></span></h2> <p>How to launch the editor from the command line.</p> <p><a name="open-file-cmdline-note" id="open-file-cmdline-note"></a></p> <h2 id="toc2"><span><a href="text-mode-editors#open-file-cmdline">open file</a></span></h2> <p>How to launch the editor from the command line with a file loaded into a buffer.</p> <p><a name="open-file-line-note" id="open-file-line-note"></a></p> <h2 id="toc3"><span><a href="text-mode-editors#open-file-line">open file on line 100</a></span></h2> <p>How to launch the editor from the command line with a file loaded and the point on line 100 of the buffer.</p> <p><a name="open-file-column-line-note" id="open-file-column-line-note"></a></p> <h2 id="toc4"><span><a href="text-mode-editors#open-file-column-line">open file on column 20 of line 100</a></span></h2> <p>How to launch the editor from the command line with a file loaded and the point on column 20 of line 100 of the buffer.</p> <p><a name="open-file-read-only-cmdline-note" id="open-file-read-only-cmdline-note"></a></p> <h2 id="toc5"><span><a href="text-mode-editors#open-file-read-only-cmdline">open file in read-only mode</a></span></h2> <p><a name="open-multiple-files-note" id="open-multiple-files-note"></a></p> <h2 id="toc6"><span><a href="text-mode-editors#open-multiple-files">open multiple files</a></span></h2> <p><a name="open-dir-cmdline-note" id="open-dir-cmdline-note"></a></p> <h2 id="toc7"><span><a href="text-mode-editors#open-dir-cmdline">open directory</a></span></h2> <p><a name="startup-file-note" id="startup-file-note"></a></p> <h2 id="toc8"><span><a href="text-mode-editors#startup-file">startup file</a></span></h2> <p><a name="skip-startup-file-note" id="skip-startup-file-note"></a></p> <h2 id="toc9"><span><a href="text-mode-editors#skip-startup-file">skip startup file</a></span></h2> <p><a name="text-editing-note" id="text-editing-note"></a></p> <h1 id="toc10"><span><a href="text-mode-editors#text-editing">Text Editing</a></span></h1> <p><a name="show-version-note" id="show-version-note"></a></p> <h2 id="toc11"><span><a href="text-mode-editors#show-version">show version</a></span></h2> <p>How to get the version of the editor.</p> <p>It is also possible to determine the version from the command line:</p> <div class="code"> <pre> <code>$ vim --version $ emacs --version $ nano --version</code> </pre></div> <p><a name="redraw-display-note" id="redraw-display-note"></a></p> <h2 id="toc12"><span><a href="text-mode-editors#redraw-display">redraw display</a></span></h2> <p>How to make the editor redraw the display.</p> <p><a name="insert-x-note" id="insert-x-note"></a></p> <h2 id="toc13"><span><a href="text-mode-editors#insert-x">insert 'x'</a></span></h2> <p>How to insert the character 'x' into a document.</p> <p><strong>vim:</strong></p> <p>One must be in insert mode to insert 'x'.</p> <p>In normal mode keys are bound to commands. The key 'x' is bound to a command which deletes the character under the point.</p> <p><strong>emacs:</strong></p> <p>In Emacs modes used for editing documents, printing characters are inserting by typing the corresponding keys. All printing characters are bound to the Emacs command <tt>self-insert-command</tt>.</p> <p><a name="insert-unicode-point-note" id="insert-unicode-point-note"></a></p> <h2 id="toc14"><span><a href="text-mode-editors#insert-unicode-point">insert by unicode point</a></span></h2> <p>How to insert a character by its 4 hex digit Unicode point.</p> <p><a name="insert-unicode-name-note" id="insert-unicode-name-note"></a></p> <h2 id="toc15"><span><a href="text-mode-editors#insert-unicode-name">insert by unicode name</a></span></h2> <p>How to insert a character by its Unicode name.</p> <p><strong>emacs:</strong></p> <p>When typing the Unicode name tab completion is available.</p> <p><a name="get-unicode-point-note" id="get-unicode-point-note"></a></p> <h2 id="toc16"><span><a href="text-mode-editors#get-unicode-point">get unicode point</a></span></h2> <p>How to get the Unicode point of the character at the point.</p> <p><strong>emacs:</strong></p> <p>Information about the character including location in the buffer, point, Unicode name, and Unicode category is displayed in a separate buffer.</p> <p><a name="cancel-note" id="cancel-note"></a></p> <h2 id="toc17"><span><a href="text-mode-editors#cancel">cancel</a></span></h2> <p>How to abort the current operation.</p> <p><strong>vim:</strong></p> <p>In all modes except for <tt>ex</tt> mode, ESC returns Vim to normal mode.</p> <p><strong>emacs:</strong></p> <p>C-g (M-x keyboard-quit) can be used in two situations in Emacs: (1) if you executed a command and are being prompted for input in the minibuffer, but would like to cancel the command without entering input, and (2) to remove an argument that was set with the C-u (M-x universal-argument) command.</p> <p>If you've entered part of a multi-keystroke command sequence and wish to cancel, C-g can be used because there aren't any multi-keystroke sequences that end with C-g.</p> <p><a name="insert-control-note" id="insert-control-note"></a></p> <h2 id="toc18"><span><a href="text-mode-editors#insert-control">insert control character</a></span></h2> <p>How to insert a literal control character.</p> <p>The control characters are assigned ASCII codes 0 through 31 and 127.</p> <p>The control characters can be entered by holding down the control key and then pressing the ASCII character with the same code as the control character plus 64 modulo 128. The control character sequences for ASCII 0 through 31 are C-@, C-A, …, C-Z, C-[, C-\, C-], C-^ and for ASCII 127 is C-?. In particular ESC is C-[. Although the ASCII letters are uppercase, it is not necessary to use the shift key when entering the control sequence.</p> <p>Both Vim and Emacs will display most of the control characters using caret notation: ^@, ^A, …, ^Z, ^[, ^\, ^], ^^, and ^? for DEL.</p> <p><strong>vim:</strong></p> <p>Some control key combinations are bound to vim commands. To insert a literal control character, precede the combination with C-v.</p> <p><strong>emacs:</strong></p> <p>Most control key combinations are bound to emacs commands. To insert a literal control character into a buffer, precede the combination with C-q.</p> <p><a name="insert-newline-note" id="insert-newline-note"></a></p> <h2 id="toc19"><span><a href="text-mode-editors#insert-newline">insert newline</a></span></h2> <p>How to insert a newline in contexts where the RET key won't insert a newline.</p> <p><strong>vim:</strong></p> <p>The <tt>C-v RET</tt> mechanism is necessary when using <tt>:map</tt> to define a key binding for a command sequence containing a newline.</p> <p><strong>emacs:</strong></p> <p>C-q C-j is necessary to put a newline in the either the search pattern or the replacement string of M-x query-replace.</p> <p><a name="auto-complete-note" id="auto-complete-note"></a></p> <h2 id="toc20"><span><a href="text-mode-editors#auto-complete">auto complete</a></span></h2> <p>How to auto complete a partially typed word using other words in the buffer.</p> <p><strong>emacs:</strong></p> <p>M-x hippie-expand will use all open buffers to find candidates to complete the word.</p> <p><a name="repeat-n-note" id="repeat-n-note"></a></p> <h2 id="toc21"><span><a href="text-mode-editors#repeat-n">repeat next command n times</a></span></h2> <p>How to repeat a command <em>n</em> times.</p> <p><strong>vim:</strong></p> <p>When in normal mode, any positive integer can be used to repeat a command multiple times.</p> <p><strong>emacs:</strong></p> <p>When given a universal argument of <em>n</em>, many emacs commands will repeat themselves <em>n</em> times, but the behavior is not universal.</p> <p><a name="repeat-4-note" id="repeat-4-note"></a></p> <h2 id="toc22"><span><a href="text-mode-editors#repeat-4">repeat next command 4 times</a></span></h2> <p>How to repeat a command 4 times.</p> <p><strong>emacs:</strong></p> <p>The <tt>C-u</tt> command defaults to 4 when no argument is provided.</p> <p><a name="repeat-16-note" id="repeat-16-note"></a></p> <h2 id="toc23"><span><a href="text-mode-editors#repeat-16">repeat next command 16 times</a></span></h2> <p>How to repeat a command 16 times.</p> <p><strong>emacs:</strong></p> <p>Typing <tt>C-u</tt> <em>n</em> times is the same as setting the universal argument to 4<sup>n</sup>.</p> <p><a name="font-size-note" id="font-size-note"></a></p> <h2 id="toc24"><span><a href="text-mode-editors#font-size">font size</a></span></h2> <p>How to adjust the font size. This can only be done when the editors are running as GUI applications.</p> <p><strong>vim:</strong></p> <p>When using MacVim use ⌘- and ⌘= to decrease or increase the font size.</p> <p>When using gVim change the font via the menu system: <tt>Edit | Select Font…</tt></p> <p><strong>emacs:</strong></p> <p>Aquamacs will adjust font size in response to ⌘= and ⌘- but GNU Emacs will not.</p> <p><a name="exit-note" id="exit-note"></a></p> <h2 id="toc25"><span><a href="text-mode-editors#exit">exit</a></span></h2> <p>How to exit the editor. If there are unsaved changes the user is prompted whether to save them.</p> <p><strong>vim:</strong></p> <p>When there are multiple tabs or panes, <tt>:q</tt> only closes the current tab or pane.</p> <p><a name="save-exit-note" id="save-exit-note"></a></p> <h2 id="toc26"><span><a href="text-mode-editors#save-exit">save changes and exit</a></span></h2> <p>How to save any unsaved changes to the current buffer and exit.</p> <p><strong>vim:</strong></p> <p>If there are multiple panes or tabs, vim does not exit but instead closes the current tab or pane.</p> <p><strong>emacs:</strong></p> <p>If there are changes to other buffers, emacs will prompt whether they should be saved.</p> <p><a name="discard-exit-note" id="discard-exit-note"></a></p> <h2 id="toc27"><span><a href="text-mode-editors#discard-exit">discard changes and exit</a></span></h2> <p>How to discard all unsaved changes and exit.</p> <p><strong>vim:</strong></p> <p>If there are other tabs or panes, vim does not exit but instead closes the current tab or pane.</p> <p><a name="mode-note" id="mode-note"></a></p> <h1 id="toc28"><span><a href="text-mode-editors#mode">Mode</a></span></h1> <p><strong>vim:</strong></p> <table class="wiki-content-table"> <tr> <th>mode</th> <th>label</th> <th>description</th> </tr> <tr> <td>normal</td> <td><span style="color: gray"><em>none</em></span></td> <td>Also called command mode. Most keys are bound to commands.</td> </tr> <tr> <td>insert</td> <td><span style="white-space: pre-wrap;">-- INSERT --</span></td> <td>Keys insert literal text into the buffer.</td> </tr> <tr> <td>replace</td> <td><span style="white-space: pre-wrap;">-- REPLACE --</span></td> <td>Like insert mode but existing text is overwritten.</td> </tr> <tr> <td>visual</td> <td><span style="white-space: pre-wrap;">-- VISUAL --</span></td> <td>Region between where cursor was at visual mode entry and current position is highlighted. If an operator is selected it will operate on the highlighted region.</td> </tr> <tr> <td>select</td> <td><span style="white-space: pre-wrap;">-- SELECT --</span></td> <td>Highlights like visual mode. Hitting a printable character deletes selection and enters insert mode.</td> </tr> <tr> <td>operator-pending</td> <td></td> <td>Entered after executing a command which expects motion keys to be used to define a region.</td> </tr> <tr> <td>cmdline</td> <td></td> <td>Cursor is in bottom row of window. Line editor commands can be entered.</td> </tr> <tr> <td>ex</td> <td></td> <td>Like cmdline mode, except that does not return to normal mode after a command is executed.</td> </tr> <tr> <th><span style="color: #efefef"><span style="white-space: pre-wrap;">_______________________</span></span></th> <th><span style="color: #efefef"><span style="white-space: pre-wrap;">_______________________</span></span></th> <th></th> </tr> </table> <p><strong>emacs:</strong></p> <p>Here are some commonly used Emacs modes:</p> <ul> <li>fundamental-mode</li> <li>text-mode</li> <li><em>markup modes:</em> HTML mode, LaTeX mode, …</li> <li><em>programming language source modes:</em> C mode, Python mode, …</li> <li>dired-mode</li> <li>shell-mode</li> <li>lisp-interaction-mode</li> </ul> <p>Each buffer has a mode which in turn determines the keybindings and the values in variables which customize the behavior of Emacs.</p> <p>When opening a file for editing in a buffer, Emacs uses the following four techniques in succession to determine the correct mode to use:</p> <ul> <li><a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables">file variables</a> in first two lines of file: <tt>-*- mode: Lisp;-*-</tt></li> <li><tt>interpreter-mode-alist</tt>: a mapping from interpreter names in the shebang to modes</li> <li><tt>magic-mode-alist</tt>: usually empty, but can map regexes applied to text in the file to modes</li> <li><tt>auto-mode-alist</tt>: maps regexes applied to the file name to modes. Usually they identify file type by suffix.</li> </ul> <p><a name="change-mode-note" id="change-mode-note"></a></p> <h2 id="toc29"><span><a href="text-mode-editors#change-mode">change mode</a></span></h2> <p><strong>vim:</strong></p> <p><a href="http://darkpan.com/files/vim.svg">VIM Mode Transition Diagram</a></p> <p>The above diagram documents how one moves between modes</p> <p>Pressing ESC twice returns vim to normal mode except when it is in ex mode. To exit ex mode type <tt>vi</tt>.</p> <p><a name="show-mode-note" id="show-mode-note"></a></p> <h2 id="toc30"><span><a href="text-mode-editors#show-mode">show mode</a></span></h2> <p><strong>vim:</strong></p> <p>Normally when vim is in insert, visual, select, or replace mode, the mode name is indicated on the bottom line of the screen between double hyphens. This behave can be turned off or on with the commands</p> <div class="code"> <pre> <code>:set noshowmode :set showmode</code> </pre></div> <p><a name="mode-doc-note" id="mode-doc-note"></a></p> <h2 id="toc31"><span><a href="text-mode-editors#mode-doc">mode documentation</a></span></h2> <p>How to get documentation for the current mode.</p> <p><a name="set-key-binding-note" id="set-key-binding-note"></a></p> <h2 id="toc32"><span><a href="text-mode-editors#set-key-binding">set key binding</a></span></h2> <p><strong>vim:</strong></p> <p><tt>:map</tt> defines a binding for normal, visual, and operator-pending modes.</p> <p>The commands <tt>:nmap</tt>, <tt>:imap</tt>, <tt>:vmap</tt>, <tt>:omap</tt>, and <tt>:cmap</tt> can be used to define commands specific to normal, insert, visual, operator-pending, and cmdline mode.</p> <p><strong>emacs:</strong></p> <p><tt>global-set-key</tt> changes the key binding for all modes. <tt>local-set-key</tt> can be used to change the key binding for the current major mode. Also <tt>global-unset-key</tt> and <tt>local-unset-key</tt> can be used to make a key have no binding.</p> <p>Here's an example of how to set a key binding in the emacs startup file <tt>init.el</tt>.</p> <div class="code"> <pre> <code>(global-set-key "\C-cb" 'revert-buffer)</code> </pre></div> <p><a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-Rebinding.html#Init-Rebinding">Emacs Key Notation</a></p> <p>The keys for printing characters are bound to the command <tt>self-insert-command</tt>.</p> <p><a name="enter-insert-note" id="enter-insert-note"></a></p> <h2 id="toc33"><span><a href="text-mode-editors#enter-insert">enter insert mode</a></span></h2> <p>How to enter insert mode on the current line.</p> <p>Only Vim has insert mode.</p> <p><a name="enter-insert-adjacent-line-note" id="enter-insert-adjacent-line-note"></a></p> <h2 id="toc34"><span><a href="text-mode-editors#enter-insert-adjacent-line">enter insert mode on adjacent line</a></span></h2> <p>How to enter insert mode by creating a new line either above or below the current line.</p> <p>Only Vim has insert mode.</p> <p><a name="ex-mode-note" id="ex-mode-note"></a></p> <h2 id="toc35"><span><a href="text-mode-editors#ex-mode">enter and exit ex mode</a></span></h2> <p>How to exit <tt>ex</tt> mode.</p> <p>Only Vim has <tt>ex</tt> mode.</p> <p><a name="movement-note" id="movement-note"></a></p> <h1 id="toc36"><span><a href="text-mode-editors#movement">Movement</a></span></h1> <p><a name="point-location-note" id="point-location-note"></a></p> <h2 id="toc37"><span><a href="text-mode-editors#point-location">location of point</a></span></h2> <p><strong>vim:</strong></p> <p>Vim calls the point the <em>cursor</em>.</p> <p><strong>emacs:</strong></p> <p>The minor modes line-number and column-number can be used to display the location of the point in the mode line:</p> <div class="code"> <pre> <code>M-x column-number-mode M-x line-number-mode</code> </pre></div> <p><a name="swap-point-mark-note" id="swap-point-mark-note"></a></p> <h2 id="toc38"><span><a href="text-mode-editors#swap-point-mark">swap point and mark</a></span></h2> <p><strong>vim:</strong></p> <p>Vim does not use the term <em>mark</em>. The documentation refers to it as "the other end of the selection".</p> <p><a name="goto-line-note" id="goto-line-note"></a></p> <h2 id="toc39"><span><a href="text-mode-editors#goto-line">goto line</a></span></h2> <p>How to go to a specific line number. The editors number the lines in the buffer starting from one.</p> <p><strong>nano:</strong></p> <p>If two arguments are provided separated by a comma, they are taken to be the line and column to which the cursor should be moved.</p> <p><a name="goto-char-note" id="goto-char-note"></a></p> <h2 id="toc40"><span><a href="text-mode-editors#goto-char">goto character</a></span></h2> <p>How to go to a character by its position in the buffer.</p> <p><a name="down-note" id="down-note"></a></p> <h2 id="toc41"><span><a href="text-mode-editors#down">down</a></span></h2> <p>How to go down one line.</p> <p><a name="up-note" id="up-note"></a></p> <h2 id="toc42"><span><a href="text-mode-editors#up">up</a></span></h2> <p>How to go up one line.</p> <p><a name="forward-note" id="forward-note"></a></p> <h2 id="toc43"><span><a href="text-mode-editors#forward">forward</a></span></h2> <p>How to go forward one character.</p> <p><strong>emacs:</strong></p> <p>In the typical case of left-to-right scripts, M-x forward-char and M-x right-char are synonyms.</p> <p>In right-to-left scripts such as Arabic M-x forward-char and M-x left-char are synonyms.</p> <p><a name="backward-note" id="backward-note"></a></p> <h2 id="toc44"><span><a href="text-mode-editors#backward">backward</a></span></h2> <p>How to go back one character.</p> <p><a name="forward-word-note" id="forward-word-note"></a></p> <h2 id="toc45"><span><a href="text-mode-editors#forward-word">forward beginning of word</a></span></h2> <p>How to advance to the beginning of the next word.</p> <p><a name="forward-word-end-note" id="forward-word-end-note"></a></p> <h2 id="toc46"><span><a href="text-mode-editors#forward-word-end">forward end of word</a></span></h2> <p>How to advance to the end of the current word or the end of the next word if already at the end of the current word.</p> <p><a name="backward-word-note" id="backward-word-note"></a></p> <h2 id="toc47"><span><a href="text-mode-editors#backward-word">backward word</a></span></h2> <p>How to go back by one word.</p> <p><a name="beginning-line-note" id="beginning-line-note"></a></p> <h2 id="toc48"><span><a href="text-mode-editors#beginning-line">beginning of line</a></span></h2> <p>How to go to the beginning of the current line.</p> <p><a name="beginning-line-nonblank-note" id="beginning-line-nonblank-note"></a></p> <h2 id="toc49"><span><a href="text-mode-editors#beginning-line-nonblank">first nonblank character of line</a></span></h2> <p>How to go to the first non-whitespace character of the current line.</p> <p><a name="end-line-note" id="end-line-note"></a></p> <h2 id="toc50"><span><a href="text-mode-editors#end-line">end of line</a></span></h2> <p>How to go to the end of the current line.</p> <p><a name="prev-sentence-note" id="prev-sentence-note"></a></p> <h2 id="toc51"><span><a href="text-mode-editors#prev-sentence">previous sentence</a></span></h2> <p>If the point is mid-sentence, how to go to the start of the sentence. If already at the start of the sentence, how to go to the start of the previous sentence.</p> <p><strong>emacs:</strong></p> <p>By default sentence boundaries are defined by periods . or question marks ? followed by whitespace.</p> <p>The variable <tt>sentence-end</tt> can be set to a regular expression to customize the definition of a sentence.</p> <p><a name="next-sentence-note" id="next-sentence-note"></a></p> <h2 id="toc52"><span><a href="text-mode-editors#next-sentence">next sentence</a></span></h2> <p>If the point is mid-sentence, how to go the the end of the sentence. If already at the end of the sentence, how to go the end of the following sentence.</p> <p><a name="start-paragraph-note" id="start-paragraph-note"></a></p> <h2 id="toc53"><span><a href="text-mode-editors#start-paragraph">start of paragraph</a></span></h2> <p>If the point is mid-paragraph, go to the start of the paragraph. If the point is already at the start of a paragraph, go to the start of the previous paragraph.</p> <p><strong>emacs:</strong></p> <p>Paragraphs are defined by blank lines.</p> <p>The behavior can be customized by setting the variables <tt>paragraph-start</tt> and <tt>paragraph-separate</tt> to appropriate regular expressions.</p> <p><a name="end-paragraph-note" id="end-paragraph-note"></a></p> <h2 id="toc54"><span><a href="text-mode-editors#end-paragraph">end of paragraph</a></span></h2> <p>If the point is mid-paragraph, go to the end of the paragraph. If the point is already at the end of a paragraph, go to the end of the following paragraph.</p> <p><a name="matching-paren-note" id="matching-paren-note"></a></p> <h2 id="toc55"><span><a href="text-mode-editors#matching-paren">matching paren, bracket, or brace</a></span></h2> <p><a name="column-20-note" id="column-20-note"></a></p> <h2 id="toc56"><span><a href="text-mode-editors#column-20">column 20</a></span></h2> <p>How to move the point to column 20 of the current line.</p> <p><a name="page-down-note" id="page-down-note"></a></p> <h2 id="toc57"><span><a href="text-mode-editors#page-down">page down</a></span></h2> <p>How to scroll the window down the buffer by one page.</p> <p>A page in this context is defined by how much can be displayed in the window. After scrolling down, none of the content that was previously visible in the window will be visible unless the end of the buffer was reached.</p> <p>After paging down, the point is placed at the top of the window.</p> <p><strong>emacs:</strong></p> <p>If the end of the buffer is already visible, Emacs beeps and does not move the point.</p> <p><strong>vim:</strong></p> <p>If the end of the buffer is already visible, Vim will place the last line at the top of the window. If the last line is already at the top of the window Vim beeps.</p> <p><a name="page-up-note" id="page-up-note"></a></p> <h2 id="toc58"><span><a href="text-mode-editors#page-up">page up</a></span></h2> <p>How to scroll the window up the buffer by one page.</p> <p><a name="half-page-down-note" id="half-page-down-note"></a></p> <h2 id="toc59"><span><a href="text-mode-editors#half-page-down">half page down</a></span></h2> <p>How to scroll the window down the buffer by half a page.</p> <p><a name="half-page-up-note" id="half-page-up-note"></a></p> <h2 id="toc60"><span><a href="text-mode-editors#half-page-up">half page up</a></span></h2> <p>How to scroll the window up the buffer by half a page.</p> <p><a name="page-other-window-note" id="page-other-window-note"></a></p> <h2 id="toc61"><span><a href="text-mode-editors#page-other-window">page other window</a></span></h2> <p>How to scroll the window down in a buffer that isn't currently selected.</p> <p><strong>emacs:</strong></p> <p>If a numeric argument is provided, the window scrolls down by that number of lines. If the numeric argument is negative the window scrolls up.</p> <p>If there is more that one other window, C-M-v operates on each of them in turn.</p> <p><a name="page-right-note" id="page-right-note"></a></p> <h2 id="toc62"><span><a href="text-mode-editors#page-right">page right</a></span></h2> <p><a name="page-left-note" id="page-left-note"></a></p> <h2 id="toc63"><span><a href="text-mode-editors#page-left">page left</a></span></h2> <p><a name="center-window-note" id="center-window-note"></a></p> <h2 id="toc64"><span><a href="text-mode-editors#center-window">center window</a></span></h2> <p>How to move the window (the visible portion of the buffer) so that the point is centered. The position of the point in the document does not change.</p> <p><strong>emacs:</strong></p> <p>Repeated use of C-l cycles the point through the positions center, top, and bottom of the window. The portion of the buffer visible in the window changes, not the position of the point in the buffer.</p> <p><a name="center-point-note" id="center-point-note"></a></p> <h2 id="toc65"><span><a href="text-mode-editors#center-point">center point</a></span></h2> <p>How to move the point to the center of the window (the visible portion of the buffer). The portion of the buffer visible in the window does not change.</p> <p><strong>vim:</strong></p> <p>M moves to the beginning of the line at the center of the window; H to the beginning of the first line at the top of the window; L to the beginning of the first line at the bottom of the window.</p> <p><strong>emacs:</strong></p> <p>Repeated use M-r cycles the point through the positions center, top, and bottom of the window. The point moves in the buffer, but the portion of the buffer visible in the window does not change.</p> <p><a name="beginning-doc-note" id="beginning-doc-note"></a></p> <h2 id="toc66"><span><a href="text-mode-editors#beginning-doc">beginning of document</a></span></h2> <p>How to move the point to the beginning of the buffer.</p> <p><a name="end-doc-note" id="end-doc-note"></a></p> <h2 id="toc67"><span><a href="text-mode-editors#end-doc">end of document</a></span></h2> <p>How to move the point to the end of the buffer.</p> <p><a name="selecting-deleting-note" id="selecting-deleting-note"></a></p> <h1 id="toc68"><span><a href="text-mode-editors#selecting-deleting">Selecting and Deleting</a></span></h1> <p><a name="del-line-note" id="del-line-note"></a></p> <h2 id="toc69"><span><a href="text-mode-editors#del-line">delete to end of line</a></span></h2> <p>Delete all characters to the end of the line.</p> <p><strong>vim:</strong></p> <p>The character under the cursor is also deleted. If the point is on the last character of the line it is the only character that will be deleted. The end-of-line character between the current and subsequent line is never deleted.</p> <p><strong>emacs:</strong></p> <p>If the point is already at the end of the line, the following line is joined to the end of the current line. Repeated use of C-k can thus be used to remove several adjacent lines.</p> <p><a name="files-buffers-note" id="files-buffers-note"></a></p> <h1 id="toc70"><span><a href="text-mode-editors#files-buffers">Files and Buffers</a></span></h1> <p><a name="pwd-note" id="pwd-note"></a></p> <h2 id="toc71"><span><a href="text-mode-editors#pwd">show current directory</a></span></h2> <p>How to show the current directory.</p> <p><a name="cd-note" id="cd-note"></a></p> <h2 id="toc72"><span><a href="text-mode-editors#cd">change current directory</a></span></h2> <p>How to change the current directory.</p> <p><strong>emacs:</strong></p> <p>A current directory is associated with each buffer. If the buffer is visiting a file the current directory will be the directory containing the file. Other buffers will have a default buffer directory which might be the current directory when emacs was launched or the user home directory. The current directory for any buffer can be changed with <tt>M-x cd</tt>.</p> <p><a name="open-file-note" id="open-file-note"></a></p> <h2 id="toc73"><span><a href="text-mode-editors#open-file">open file</a></span></h2> <p>How to open a file for editing. A copy of the file is made in a buffer.</p> <p><strong>emacs</strong></p> <p>Emacs can edit files on remote machines. The format for specifying a remote file is</p> <div class="code"> <pre> <code>/USER@MACHINE:/PATH/TO/FILE</code> </pre></div> <p>The format for editing a file as root is</p> <div class="code"> <pre> <code>/sudo::/PATH/TO/FILE</code> </pre></div> <p><a name="open-file-read-only-note" id="open-file-read-only-note"></a></p> <h2 id="toc74"><span><a href="text-mode-editors#open-file-read-only">open file read only</a></span></h2> <p>How to open a file for viewing only.</p> <p><a name="show-buffer-file-name-note" id="show-buffer-file-name-note"></a></p> <h2 id="toc75"><span><a href="text-mode-editors#show-buffer-file-name">show buffer file name</a></span></h2> <p>How to show the complete path name for the file the buffer is visiting.</p> <p><a name="list-buffers-note" id="list-buffers-note"></a></p> <h2 id="toc76"><span><a href="text-mode-editors#list-buffers">list buffers</a></span></h2> <p><a name="switch-buffer-note" id="switch-buffer-note"></a></p> <h2 id="toc77"><span><a href="text-mode-editors#switch-buffer">switch buffer</a></span></h2> <p><a name="diff-buffer-file-note" id="diff-buffer-file-note"></a></p> <h2 id="toc78"><span><a href="text-mode-editors#diff-buffer-file">diff buffer and file</a></span></h2> <p><a name="save-buffer-note" id="save-buffer-note"></a></p> <h2 id="toc79"><span><a href="text-mode-editors#save-buffer">save buffer</a></span></h2> <p><a name="save-all-buffers-note" id="save-all-buffers-note"></a></p> <h2 id="toc80"><span><a href="text-mode-editors#save-all-buffers">save all buffers</a></span></h2> <p><a name="revert-buffer-note" id="revert-buffer-note"></a></p> <h2 id="toc81"><span><a href="text-mode-editors#revert-buffer">revert buffer</a></span></h2> <p><a name="write-buffer-to-different-file-note" id="write-buffer-to-different-file-note"></a></p> <h2 id="toc82"><span><a href="text-mode-editors#write-buffer-to-different-file">write buffer to different file</a></span></h2> <p><a name="write-region-to-file-note" id="write-region-to-file-note"></a></p> <h2 id="toc83"><span><a href="text-mode-editors#write-region-to-file">write region to file</a></span></h2> <p><a name="insert-file-note" id="insert-file-note"></a></p> <h2 id="toc84"><span><a href="text-mode-editors#insert-file">insert file</a></span></h2> <p><a name="minibuffer-note" id="minibuffer-note"></a></p> <h1 id="toc85"><span><a href="text-mode-editors#minibuffer">Minibuffer</a></span></h1> <p>The minibuffer is a line at the bottom of the frame which Emacs uses to prompt the user for an argument.</p> <p>The Vim analog of the minibuffer is the command line. It also appears at the bottom of the window. The Vim command line is used for entering a command and all of its arguments, whereas the Emacs minibuffer is generally used for entering a single argument. However, in the case of M-: and M-! that argument is a Lisp expression to be evaluated or a shell command to be evaluated.</p> <p>Both the Emacs minibuffer and the Vim command line offer tab completion.</p> <p>The Emacs minibuffer is to a certain extent a buffer like any other. Commands used to navigate and edit other buffers are general available in the minibuffer. It is an error to call a command which solicits an argument via the minibuffer when already in the minibuffer.</p> <p>The Vim command line is a mode distinct from the other Vim modes: command mode, insert mode, and visual mode. It provides its own set of commands for manipulating the text which appears on the command line.</p> <p><a name="ido-note" id="ido-note"></a></p> <h1 id="toc86"><span><a href="text-mode-editors#ido">Ido</a></span></h1> <p>The Ido library ships with Emacs. It modifies the behavior of the minibuffer when prompting for buffer names and file names.</p> <p>When the minibuffer is in <tt>ido-mode</tt>, TAB completion is replaced by a match list which is updated each time a character of input is entered. Hitting RET selects the first item in the match list. The arrow keys can be used to bring a different match up to the front of the list.</p> <p>The rules for finding matches can be customized. By default matches for which the input string is a prefix are listed first, following by matches for which the input string is a substring.</p> <p>Another feature of <tt>ido-mode</tt> is the directory history. This is a list of all the directories that have been visited in <tt>ido-mode</tt>, sorted by time of most recent visit. The directory history is only relevant when searching for files, not buffers. When searching for files the input is divided by <tt>ido-mode</tt> into the dirname and basename portion. Older directories in the directory history can be recalled with <tt>M-p</tt>.</p> <p>To enable ido-mode, put the following in the emacs startup file:.</p> <div class="code"> <pre> <code>(require 'ido) (ido-mode t)</code> </pre></div> <p><a name="history-note" id="history-note"></a></p> <h1 id="toc87"><span><a href="text-mode-editors#history">History</a></span></h1> <p>Vim and Emacs keep a history for each buffer. Every command and edit which modifies the buffer can be undone, and every command that was undone can be redone.</p> <p>As a buffer is being edited, the history of the buffer can be represented as a sequence of buffer versions connected by the commands which were used to transition between them. If the redo command did not have to be supported, the undo operation could be implemented by deleting the most recent version from the buffer history. The redo command introduces complexity which Vim and Emacs handle in different ways.</p> <p><strong>vim:</strong></p> <p>Vim represents buffer history with a tree of versions. Each version was created from its parent in the tree by a command. A branch is created when a user undoes one or more edits and then starts to edit a non-leaf version. The undo and redo commands only permit moving between version on the current branch, but Vim provides two mechanisms for recovering versions from other branches. Vim numbers versions sequentially in the order in which they were first created. Providing the :undo command with an integer argument will recover the version. One can also use the g- or g+ commands to move to a version number relative to the current version number. Vim also records a timestamp whenever the buffer is changes, permitting the user to recover buffer version that was current 5 minutes ago.</p> <p><strong>emacs:</strong></p> <p>Emacs keeps its buffer version history in a sequential list. Undo is implemented not by deleting from the end of the list, but by adding a new version to the list created by a command which reverses the command which is being undone. Thus the undo command is a redo when the command that is being undone was itself an undo. However, there is a wrinkle which is necessary to make it possible to go back more than one version. When the undo command is issued multiple times in succession, the commands which reverse the commands being undone are not added to the version history until a command other than undo is made. This other command is said to break the undo chain. The <a href="text-mode-editors#undo-last-cmd-not-undone">undo-only</a> command is useful when one breaks the undo chain accidentally.</p> <p><a name="repeat-note" id="repeat-note"></a></p> <h2 id="toc88"><span><a href="text-mode-editors#repeat">repeat</a></span></h2> <p>How to repeat the last command.</p> <p><a name="undo-note" id="undo-note"></a></p> <h2 id="toc89"><span><a href="text-mode-editors#undo">undo</a></span></h2> <p>How to undo the last command.</p> <p><a name="redo-note" id="redo-note"></a></p> <h2 id="toc90"><span><a href="text-mode-editors#redo">redo</a></span></h2> <p>How to redo a command that was just undone.</p> <p><a name="undo-last-cmd-not-undone-note" id="undo-last-cmd-not-undone-note"></a></p> <h2 id="toc91"><span><a href="text-mode-editors#undo-last-cmd-not-undone">undo last command not undone</a></span></h2> <p><strong>emacs:</strong></p> <p>When using Emacs one may sometimes break the undo chain accidentally. For example, suppose that one wanted to undo the last 8 changes. If one hit undo 7 times and then accidentally moved the cursor, the undo chain would be broken and Emacs would insert 7 undo commands onto the version history. Now the desired version is 15 versions back. The solution is to use <tt>M-x undo-only</tt> which skips all versions created by the undo command and the versions that were undone by those undo commands.</p> <p><a name="goto-version-note" id="goto-version-note"></a></p> <h2 id="toc92"><span><a href="text-mode-editors#goto-version">goto version</a></span></h2> <p>Put the buffer into the state it had at the specified version.</p> <p><strong>vim:</strong></p> <p>Vim numbers all versions of the buffer sequentially from 1 in the order that they were first created.</p> <p><a name="goto-prev-version-note" id="goto-prev-version-note"></a></p> <h2 id="toc93"><span><a href="text-mode-editors#goto-prev-version">goto previous version</a></span></h2> <p>Put the buffer into the state it had the specified number of versions ago.</p> <p><a name="goto-next-version-note" id="goto-next-version-note"></a></p> <h2 id="toc94"><span><a href="text-mode-editors#goto-next-version">goto next version</a></span></h2> <p>When not currently at the most recent version, this command puts the buffer in a state a specified number of versions more recent.</p> <p><a name="go-back-in-time-note" id="go-back-in-time-note"></a></p> <h2 id="toc95"><span><a href="text-mode-editors#go-back-in-time">go back in time</a></span></h2> <p>Put the buffer in the state it had the specified amount of time ago.</p> <p><a name="go-forward-in-time-note" id="go-forward-in-time-note"></a></p> <h2 id="toc96"><span><a href="text-mode-editors#go-forward-in-time">go forward in time</a></span></h2> <p>When not currently at the most recent version, this command puts the buffer in state that it had at the specified amount of time after it had the current buffer state.</p> <p><a name="goto-saved-version-note" id="goto-saved-version-note"></a></p> <h2 id="toc97"><span><a href="text-mode-editors#goto-saved-version">goto saved version</a></span></h2> <p><a name="keystroke-history-note" id="keystroke-history-note"></a></p> <h2 id="toc98"><span><a href="text-mode-editors#keystroke-history">keystroke history</a></span></h2> <p><a name="undo-branches-note" id="undo-branches-note"></a></p> <h2 id="toc99"><span><a href="text-mode-editors#undo-branches">undo branches</a></span></h2> <p><a name="searching-replacing-note" id="searching-replacing-note"></a></p> <h1 id="toc100"><span><a href="text-mode-editors#searching-replacing">Searching and Replacing</a></span></h1> <p><a name="sorting-note" id="sorting-note"></a></p> <h1 id="toc101"><span><a href="text-mode-editors#sorting">Sorting and Counting</a></span></h1> <p><a name="sort-note" id="sort-note"></a></p> <h2 id="toc102"><span><a href="text-mode-editors#sort">sort region</a></span></h2> <p>How to sort the lines in a region.</p> <p><a name="numeric-sort-note" id="numeric-sort-note"></a></p> <h2 id="toc103"><span><a href="text-mode-editors#numeric-sort">numeric sort</a></span></h2> <p>How to sort the lines in the region numerically.</p> <p><a name="sort-field-note" id="sort-field-note"></a></p> <h2 id="toc104"><span><a href="text-mode-editors#sort-field">sort by 2nd field</a></span></h2> <p>How to sort the lines in a region by the second field where the fields are whitespace delimited.</p> <p><a name="sort-fixed-width-note" id="sort-fixed-width-note"></a></p> <h2 id="toc105"><span><a href="text-mode-editors#sort-fixed-width">sort by fixed width column</a></span></h2> <p>How to sort the lines by a column when the columns are fixed width.</p> <p><a name="reverse-note" id="reverse-note"></a></p> <h2 id="toc106"><span><a href="text-mode-editors#reverse">reverse</a></span></h2> <p>How to reverse the lines in a region.</p> <p><a name="count-lines-words-chars-note" id="count-lines-words-chars-note"></a></p> <h2 id="toc107"><span><a href="text-mode-editors#count-lines-words-chars">count lines, words, and chars in document</a></span></h2> <p>How to count the number of lines, words, and characters in the document.</p> <p><a name="count-regex-note" id="count-regex-note"></a></p> <h2 id="toc108"><span><a href="text-mode-editors#count-regex">count regex matches in region</a></span></h2> <p>How to count the number of strings in a region which match a regular expression.</p> <p><a name="case-note" id="case-note"></a></p> <h1 id="toc109"><span><a href="text-mode-editors#case">Case</a></span></h1> <p><a name="uppercase-word-note" id="uppercase-word-note"></a></p> <h2 id="toc110"><span><a href="text-mode-editors#uppercase-word">uppercase word</a></span></h2> <p><a name="lowercase-word-note" id="lowercase-word-note"></a></p> <h2 id="toc111"><span><a href="text-mode-editors#lowercase-word">lowercase word</a></span></h2> <p><a name="capitalize-word-note" id="capitalize-word-note"></a></p> <h2 id="toc112"><span><a href="text-mode-editors#capitalize-word">capitalize word</a></span></h2> <p><a name="uppercase-region-note" id="uppercase-region-note"></a></p> <h2 id="toc113"><span><a href="text-mode-editors#uppercase-region">uppercase region</a></span></h2> <p><a name="lowercase-region-note" id="lowercase-region-note"></a></p> <h2 id="toc114"><span><a href="text-mode-editors#lowercase-region">lowercase region</a></span></h2> <p><a name="title-case-region-note" id="title-case-region-note"></a></p> <h2 id="toc115"><span><a href="text-mode-editors#title-case-region">title-case region</a></span></h2> <p><a name="indentation-note" id="indentation-note"></a></p> <h1 id="toc116"><span><a href="text-mode-editors#indentation">Indentation and Rectangles</a></span></h1> <p><a name="spelling-note" id="spelling-note"></a></p> <h1 id="toc117"><span><a href="text-mode-editors#spelling">Spelling</a></span></h1> <p><a name="panes-note" id="panes-note"></a></p> <h1 id="toc118"><span><a href="text-mode-editors#panes">Panes</a></span></h1> <p><a name="macros-note" id="macros-note"></a></p> <h1 id="toc119"><span><a href="text-mode-editors#macros">Macros</a></span></h1> <p><a name="ascii-art-note" id="ascii-art-note"></a></p> <h1 id="toc120"><span><a href="text-mode-editors#ascii-art">ASCII Art</a></span></h1> <p><a name="org-note" id="org-note"></a></p> <h1 id="toc121"><span><a href="text-mode-editors#org">Org</a></span></h1> <p><a name="intl-note" id="intl-note"></a></p> <h1 id="toc122"><span><a href="text-mode-editors#intl">Input Methods and Encodings</a></span></h1> <p><a name="insert-unicode-note" id="insert-unicode-note"></a></p> <h2 id="toc123"><span><a href="text-mode-editors#insert-unicode">insert unicode character</a></span></h2> <p><a href="http://unicode.org/charts/charindex.html">Unicode Character Name Index</a></p> <p>How to insert a unicode character by name or by 4-hex code.</p> <p><strong>vim:</strong></p> <p>For Unicode characters outside of the BMP, use a capital U and 8 hex characters. This will enter the code for the Egyptian hieroglyph depicting Ra seated with an ankh:</p> <div class="code"> <pre> <code>C-v U 0001305b</code> </pre></div> <p><a name="set-input-method-note" id="set-input-method-note"></a></p> <h2 id="toc124"><span><a href="text-mode-editors#set-input-method">set input method</a></span></h2> <p>How to set the input method.</p> <p>Input methods provide a more convenient method of entering non-English script. Some input methods remap the keyboard to a configuration used in a non-English speaking country. Other input methods preserve the English QWERTY layout but remap digraphs or combining characters to characters which are otherwise unavailable.</p> <p><a name="list-input-methods-note" id="list-input-methods-note"></a></p> <h2 id="toc125"><span><a href="text-mode-editors#list-input-methods">list input method</a></span></h2> <p>List the available input methods.</p> <p>Emacs 24.1 has 187 input methods. We describe a select few input methods in the following table:</p> <table class="wiki-content-table"> <tr> <th>input method</th> <th>description</th> </tr> <tr> <td>arabic</td> <td>Keys mapped in a manner popularized by the <a href="http://upload.wikimedia.org/wikipedia/commons/thumb/a/af/KB_Arabic.svg/800px-KB_Arabic.svg.png">IBM PC</a>. This keyboard places letters in the traditional locations used by Arabic typewriters.<br /> <br /> The positions of the letters must be memorized; there is no input method which allows someone who knows the Arabic letters and the QWERTY keyboard to predict the location of the letters.</td> </tr> <tr> <td>cyrillic-jcuken</td> <td><a href="http://upload.wikimedia.org/wikipedia/commons/thumb/6/60/KB_Russian.svg/800px-KB_Russian.svg.png">JCUKEN keyboard</a>. This is the most common keyboard layout in Russia.</td> </tr> <tr> <td>cyrillic-yawerty</td> <td>Places letters where phonologically similar Latin letters are found on the QWERTY keyboard. Note the following substitutions:<br /> <br /> q:я w:в y:ы u:у [:ш ]:щ f:ф h:х j:й x:ь c:ц v:ж</td> </tr> <tr> <td>french-azerty</td> <td><a href="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b9/KB_France.svg/800px-KB_France.svg.png">French AZERTY keyboard</a>. This is the most common keyboard layout in France.</td> </tr> <tr> <td>french-postfix</td> <td>QWERTY keyboard. Use <span style="white-space: pre-wrap;">`</span> ' ^ " after vowels to create accented vowels. Use , after c to create ce cedille. Use <span style="white-space: pre-wrap;"> << </span> and <span style="white-space: pre-wrap;">>></span> to create guillemots.</td> </tr> <tr> <td>german</td> <td><a href="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/German-T2-Keyboard-Prototype-May-2012.jpg/880px-German-T2-Keyboard-Prototype-May-2012.jpg">German QWERTZ keyboard</a>. This is the most common keyboard layout in Germany.</td> </tr> <tr> <td>german-posfix</td> <td>QWERTY keyboard. Use ae, oe, ue, and sz digraphs to create the special letters.</td> </tr> <tr> <td>german-prefix</td> <td>QWERTY keyboard. Use double quote " before vowel to create umlaut. Use " before s to create long s.</td> </tr> <tr> <td>greek</td> <td>Places letters where the corresponding Latin letters are found on the QWERTY keyboard. Note the following substitutions:<br /> <br /> w:ς y:υ u:θ f:φ h:η j:ξ x:χ c:ψ v:ω<br /> <br /> Since 1982 modern Greek only uses the acute accent and the dieresis which can be entered with the ; (acute) and : (dieresis) prefixes. To enter a literal ; or : use q or Q. Use ;< or ;> for guillemots.<br /> <br /> Ancient Greek is written using the polytonic system which also has a grave accent, circumflex, and rough breathing mark. Unicode provides code points for letters marked with these diacritics, but there is no Emacs input method for them.</td> </tr> <tr> <td>japanese</td> <td>QWERTY keyboard. Type in romanji and the characters are converted to kana on the fly. In a second pass some of the kana are converted to kanji on the fly.</td> </tr> <tr> <td>spanish-keyboard</td> <td>A layout close to the layout used in <a href="http://upload.wikimedia.org/wikipedia/commons/thumb/7/74/KB_Spanish.svg/800px-KB_Spanish.svg.png">Spain</a> and Latin America.</td> </tr> <tr> <td>spanish-postfix</td> <td>QWERTY keyboard. Use suffix ' ~ " for accents. Double suffix (n~~ -> n~) to prevent accent. Use !/ and ?/ for upside down punctuation.</td> </tr> <tr> <td>spanish-prefix</td> <td>QWERTY keyboard. Use prefix ' ~ " for accents. Use ~! and ~? for upside down punctuation. Use ~< and ~> for guillemots.</td> </tr> <tr> <td><span style="color: white"><span style="white-space: pre-wrap;">____________________</span></span></td> <td></td> </tr> </table> <p><a name="toggle-input-method-note" id="toggle-input-method-note"></a></p> <h2 id="toc126"><span><a href="text-mode-editors#toggle-input-method">enable/disable input method</a></span></h2> <p>Used to turn off or re-enable an input method.</p> <p><a name="describe-input-method-note" id="describe-input-method-note"></a></p> <h2 id="toc127"><span><a href="text-mode-editors#describe-input-method">describe input method</a></span></h2> <p>Document for an input method. By default the current input method is described.</p> <p><a name="help-note" id="help-note"></a></p> <h1 id="toc128"><span><a href="text-mode-editors#help">Help</a></span></h1> <p><a name="show-key-binding-note" id="show-key-binding-note"></a></p> <h2 id="toc129"><span><a href="text-mode-editors#show-key-binding">show key binding</a></span></h2> <p>How to show the function invoked by a key.</p> <p><strong>vim:</strong></p> <p>In Vim the key is the only name for a function. Here is the notation to see the function bound to a control character:</p> <div class="code"> <pre> <code>:help CTRL-B</code> </pre></div> <p>To see the function bound to a command available in insert mode or visual mode:</p> <div class="code"> <pre> <code>:help i_CTRL-O :help v_CTRL-]</code> </pre></div> <p><strong>emacs:</strong></p> <p><tt>describe-key-briefly</tt> shows the function invoked by the key; <tt>describe-key</tt> shows the function and its documentation.</p> <p><a name="browse-files-note" id="browse-files-note"></a></p> <h1 id="toc130"><span><a href="text-mode-editors#browse-files">Browse Files</a></span></h1> <p><a name="shell-note" id="shell-note"></a></p> <h1 id="toc131"><span><a href="text-mode-editors#shell">Shell</a></span></h1> <p><strong>emacs:</strong></p> <p>Emac provides two modes for running external shells: <tt>shell-mode</tt> and <tt>term-mode</tt>.</p> <p><tt>shell-mode</tt> buffers behave more like Emacs edit buffers. It is possible to use the movement commands and the edit commands to change a previous command. Hitting RET then runs the modified version of the command. It is also possible to edit the results of the commands, which might be useful when cleaning up a shell session before sharing it. The arrow keys are interpreted by Emacs, but <tt>M-p</tt> and <tt>M-n</tt> to recall commands from the command history.</p> <p>By default, the buffer is <tt>*shell*</tt>. Use <tt>C-u M-x shell</tt> to be prompted for a different name.</p> <p>Commands which expect ANSI escape support do not work in a <tt>shell-mode</tt> buffer, e.g. fish, less, tmux, vi, or emacs itself. For such commands, one can use <tt>term-mode</tt>. We describe <tt>term-mode</tt> as it behaves when the 3rd party library <tt>multi-term.el</tt> is installed. <tt>multi-term.el</tt> has these advantages:</p> <ul> <li>Can create more than one terminal buffer.</li> <li>Control and Meta modified keystrokes are sent to Emacs instead of the terminal process.</li> <li>No toggle between line mode and character mode.</li> </ul> <p><tt>term-mode</tt> under <tt>multi-term.el</tt> has quirks that can be confusing. For example, <tt>M-DELETE</tt> is interpreted by Emacs and erases part of the current command in the buffer, yet the characters being erased have already been sent to the shell.</p> <p>Here is a summary of how keystrokes are handled in <tt>shell-mode</tt> and <tt>term-mode</tt> with <tt>multi-term.el</tt> installed:</p> <table class="wiki-content-table"> <tr> <th></th> <th>shell-mode</th> <th>term-mode w/ multi-term</th> </tr> <tr> <td>RET</td> <td>current line to process</td> <td>RET to process</td> </tr> <tr> <td>C-c C-c</td> <td>C-c to process</td> <td>C-c to process</td> </tr> <tr> <td>C-c KEY</td> <td>C-c KEY to emacs</td> <td>C-c KEY to emacs</td> </tr> <tr> <td>KEY</td> <td>KEY to emacs</td> <td>KEY to process</td> </tr> <tr> <td>M-KEY</td> <td>M-KEY to emacs</td> <td>M-KEY to emacs</td> </tr> <tr> <td>C-KEY</td> <td>C-KEY to emacs</td> <td>C-KEY to emacs</td> </tr> </table> <p><a name="shell-buffer-note" id="shell-buffer-note"></a></p> <h2 id="toc132"><span><a href="text-mode-editors#shell-buffer">open shell buffer</a></span></h2> <p><a name="shell-cmd-note" id="shell-cmd-note"></a></p> <h2 id="toc133"><span><a href="text-mode-editors#shell-cmd">execute shell command</a></span></h2> <p><a name="region-to-shell-cmd-note" id="region-to-shell-cmd-note"></a></p> <h2 id="toc134"><span><a href="text-mode-editors#region-to-shell-cmd">send region to shell command</a></span></h2> <p><a name="doc-to-shell-cmd-note" id="doc-to-shell-cmd-note"></a></p> <h2 id="toc135"><span><a href="text-mode-editors#doc-to-shell-cmd">send document to shell command</a></span></h2> <p><a name="grep-note" id="grep-note"></a></p> <h1 id="toc136"><span><a href="text-mode-editors#grep">Grep</a></span></h1> <p><strong>vim:</strong></p> <p>After performing a <tt>grep</tt>, the <tt>:cw</tt> or <tt>:copen</tt> command can be used to open the matching lines in a quickfix buffer. The quickfix buffer can be used to navigate to locations in the source files.</p> <p>Vim has a command called <tt>:vimgrep</tt> which can be used in place of <tt>:grep</tt>. <tt>:vimgrep</tt> is an internal command and hence it works on systems where <tt>:grep</tt> is not installed. It does not have any option flags, however.</p> <p>Running <tt>:grep</tt> or <tt>:vimgrep</tt> puts the results in a single quickfix buffer and hence overwrites the results of a previous search. The variants <tt>:lgrep</tt> and <tt>:lvimgrep</tt> put the results in a quickfix buffer which is local to the current buffer. The commands for navigating a local quick fix buffer are different: <tt>:ln</tt>, <tt>:lp</tt>, <tt>:lnf</tt>, <tt>:lcl</tt>.</p> <p><strong>emacs:</strong></p> <p>Emacs provides commands for running <tt>grep</tt> and displaying the results in a <tt>grep-mode</tt> buffer. The advantage of displaying the results in <tt>grep-mode</tt> is that each match is a hyperlink pointing to the location of the match in its original file. <tt>grep-mode</tt> is a child mode of <tt>compilation-mode</tt>.</p> <p>For the hyperlinks in <tt>grep-mode</tt> to work, the output of the <tt>grep</tt> must have file names and line numbers, which is why<tt>grep</tt> is invoked with the <tt>-nH</tt> flags.</p> <p>When invoking <tt>M-x grep</tt>, Emacs provides the command that it is going to execute and lets the user edit it. The user must add the search term and the name of the files to search. The user can change the flags to search directories recursively, i.e.<tt>grep -r</tt>. The user can even use a different command entirely, such as a combination of <tt>find</tt> and <tt>xargs grep</tt>. The only difference between <tt>M-x grep</tt> and <tt>M-x find-grep</tt> is the default choice for the command and flags. These choices can be changed by setting the <tt>grep-command</tt> and <tt>grep-find-command</tt> variables.</p> <p>There is a command line tool <tt>ag</tt> which can be used as a replacement for <tt>grep -r</tt> or <tt>find | xargs grep</tt>. It has simpler syntax for invocation, and will use version control ignore files such as <tt>.gitignore</tt> to select the files to be searched intelligently. To install <tt>ag</tt>, look for a package name such as <tt>the_silver_searcher</tt> or <tt>silvesearcher-ag</tt>.</p> <p><tt>ag-mode</tt>, which must be installed, invokes <tt>ag</tt> with the correct arguments so that the matches can be displayed in an Emacs buffer. Whereas <tt>M-x grep</tt> and <tt>M-x find-grep</tt> use a single <tt>*grep*</tt> buffer and replace the results of a previous search, <tt>ag-mode</tt> will create a new buffer for each search.</p> <p><a name="tags-note" id="tags-note"></a></p> <h1 id="toc137"><span><a href="text-mode-editors#tags">Tags</a></span></h1> <p>How to create emacs tags for all files in <tt>dir1</tt> and <tt>dir2</tt> with the suffix <tt>.rb</tt>:</p> <div class="code"> <pre> <code>find dir1 dir2 -name '*.rb' | xargs etags</code> </pre></div> <p><a name="diff-note" id="diff-note"></a></p> <h1 id="toc138"><span><a href="text-mode-editors#diff">Diff</a></span></h1> <p><a name="git-note" id="git-note"></a></p> <h1 id="toc139"><span><a href="text-mode-editors#git">Git</a></span></h1> <p><a name="compile-note" id="compile-note"></a></p> <h1 id="toc140"><span><a href="text-mode-editors#compile">Compile</a></span></h1> <p><a name="debug-note" id="debug-note"></a></p> <h1 id="toc141"><span><a href="text-mode-editors#debug">Debug</a></span></h1> <p><a name="lisp-interaction-note" id="lisp-interaction-note"></a></p> <h1 id="toc142"><span><a href="text-mode-editors#lisp-interaction">Lisp Interaction</a></span></h1> <p><a name="syntax-highlighting-note" id="syntax-highlighting-note"></a></p> <h1 id="toc143"><span><a href="text-mode-editors#syntax-highlighting">Syntax Highlighting</a></span></h1> <p><a name="programming" id="programming"></a></p> <h1 id="toc144"><span><a href="text-mode-editors#top">Programming</a></span></h1> <table class="wiki-content-table"> <tr> <th></th> <th><a name="variables" id="variables"></a><a href="text-mode-editors#vimscript">vimscript</a></th> <th colspan="2"><a href="text-mode-editors#emacs-lisp">emacs lisp</a></th> </tr> <tr> <td>startup script</td> <td>~/.vimrc</td> <td>~/.emacs.d/init.el</td> </tr> <tr> <td>execute file</td> <td>:source foo.vim</td> <td>M-x load-file foo.el</td> </tr> <tr> <td>execute function</td> <td></td> <td>M-: (foo)<br /> <span style="color: gray"><em>if interactively callable:</em></span><br /> M-x foo</td> </tr> <tr> <td>execute command</td> <td>normal x</td> <td></td> </tr> <tr> <td>set variable</td> <td>let i = 1</td> <td>(setq i 1)</td> </tr> <tr> <td>display variable</td> <td>echo i</td> <td>i</td> </tr> <tr> <td>delete variable</td> <td>unlet i<br /> <span style="color: gray"><em>no error msg if doesn't exist:</em></span><br /> unlet! i</td> <td></td> </tr> <tr> <td>show variables</td> <td>let</td> <td></td> </tr> <tr> <td>global variable</td> <td>let g:foo = 42</td> <td></td> </tr> <tr> <td>script local variable</td> <td>let s:foo = 42</td> <td></td> </tr> <tr> <td>window local variable</td> <td>let w:foo = 42</td> <td></td> </tr> <tr> <td>file local variable</td> <td></td> <td></td> </tr> <tr> <td>buffer local variable</td> <td>let b:foo = 42</td> <td></td> </tr> <tr> <td>end-of-line comment</td> <td>echo 1 + 1 " addition</td> <td>(+ 1 1) ; addition</td> </tr> <tr> <th colspan="3"><a name="arith-logic" id="arith-logic"></a>arithmetic and logic</th> </tr> <tr> <th></th> <th>vimscript</th> <th colspan="2">emacs lisp</th> </tr> <tr> <td>falsehoods</td> <td></td> <td></td> </tr> <tr> <td>logical operators</td> <td>&& <span style="white-space: pre-wrap;">||</span> !</td> <td></td> </tr> <tr> <td>relational operators</td> <td>== != < > <= >=</td> <td></td> </tr> <tr> <td>conditional expression</td> <td>x > 0 ? x : -x</td> <td>(if (> x 0) x (- x))</td> </tr> <tr> <td>arithmetic operators</td> <td>+ - * / %</td> <td></td> </tr> <tr> <td>float division of integers</td> <td>n * 1.0 / m</td> <td></td> </tr> <tr> <th colspan="3"><a name="str" id="str"></a>strings</th> </tr> <tr> <th></th> <th>vimscript</th> <th colspan="2">emacs lisp</th> </tr> <tr> <td>literal</td> <td>"don't say \"no\""<br /> 'don''t say "no"'</td> <td></td> </tr> <tr> <td>escapes</td> <td><span style="color: gray"><em>in double quote:</em></span><br /> \n</td> <td></td> </tr> <tr> <td>concatenate</td> <td>"Hello, " . "World!"</td> <td></td> </tr> <tr> <td>length</td> <td>strlen("lorem")</td> <td></td> </tr> <tr> <th colspan="3"><a name="list" id="list"></a>lists</th> </tr> <tr> <th></th> <th>vimscript</th> <th colspan="2">emacs lisp</th> </tr> <tr> <th colspan="3"><a name="dict" id="dict"></a>dictionaries</th> </tr> <tr> <th></th> <th>vimscript</th> <th colspan="2">emacs lisp</th> </tr> <tr> <th colspan="3"><a name="func" id="func"></a>functions</th> </tr> <tr> <th></th> <th>vimscript</th> <th colspan="2">emacs lisp</th> </tr> <tr> <td>define function</td> <td>function Add(x, y)<br /> <span style="white-space: pre-wrap;"> </span>return a:x + a:y<br /> endfunction</td> <td>(defun add (x y) (+ x y))</td> </tr> <tr> <td>invoke function</td> <td>echo Add(1, 2)<br /> <span style="color: gray"><em>outside of expression:</em></span><br /> call Add(1, 2)</td> <td>(add 1 2)</td> </tr> <tr> <td>list udfs</td> <td>function</td> <td></td> </tr> <tr> <td>delete function</td> <td>delfunction Add</td> <td></td> </tr> <tr> <th colspan="3"><a name="exec-ctrl" id="exec-ctrl"></a>execution control</th> </tr> <tr> <th></th> <th>vimscript</th> <th colspan="2">emacs lisp</th> </tr> <tr> <td>if</td> <td>if i > 0<br /> <span style="white-space: pre-wrap;"> </span>echo "i is positive"<br /> endif</td> <td></td> </tr> <tr> <td>while loop</td> <td>while i < 10<br /> <span style="white-space: pre-wrap;"> </span>echo "i is" i<br /> <span style="white-space: pre-wrap;"> </span>let i += 1<br /> endwhile</td> <td></td> </tr> <tr> <td>for loop</td> <td>for i in range(0, 9)<br /> <span style="white-space: pre-wrap;"> </span>echo "i is" i<br /> <span style="white-space: pre-wrap;"> </span>let i += 1<br /> endfor</td> <td></td> </tr> <tr> <th colspan="3"><a name="lib-mod" id="lib-mod"></a>libraries and namespaces</th> </tr> <tr> <th></th> <th>vimscript</th> <th colspan="2">emacs lisp</th> </tr> <tr> <td>show load path</td> <td>:set runtimepath?</td> <td></td> </tr> <tr> <td>append to load path</td> <td></td> <td></td> </tr> <tr> <td>load library</td> <td>runtime foo.vim</td> <td></td> </tr> </table> <p><a name="vimscript" id="vimscript"></a></p> <h1 id="toc145"><span><a href="text-mode-editors#programming">Vimscript</a></span></h1> <p><a href="http://vimdoc.sourceforge.net/htmldoc/usr_41.html">Vim Documentation: usr_41</a></p> <p><a name="emacs-lisp" id="emacs-lisp"></a></p> <h1 id="toc146"><span><a href="text-mode-editors#programming">Emacs Lisp</a></span></h1> <p><a href="http://www.gnu.org/software/emacs/manual/html_node/elisp/index.html">Emacs Lisp</a></p> <p><a name="vim" id="vim"></a><a name="emacs" id="emacs"></a><a name="nano" id="nano"></a><a name="doc" id="doc"></a></p> <h1 id="toc147"><span><a href="text-mode-editors#top">Documentation</a></span></h1> <p><a href="http://vimdoc.sourceforge.net/htmldoc/usr_toc.html">Vim documentation</a><br /> <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/index.html">GNU Emacs Manual</a><br /> <a href="http://www.nano-editor.org/dist/v2.2/nano.html">nano Command Manual</a></p> <p><a name="terminology" id="terminology"></a></p> <h1 id="toc148"><span><a href="text-mode-editors#top">Terminology</a></span></h1> <p><strong>key binding</strong></p> <p>A key binding is a mapping from a keystroke or a sequence of keystrokes to an editor command. When the keybinding is in effect, pressing the keystroke(s) invokes the command.</p> <p>A keystroke is an operating system event generated when the user presses a key on the keyboard, possibly in combination with a modifier key such as shift, control, or meta.</p> <p>Sometimes there is no key for meta. Emacs will interpret an ESC-followed-by-keystroke sequence as the meta modified version of the keystroke. In the past there were keyboards that had a key labelled Meta, such as the <a href="http://upload.wikimedia.org/wikipedia/commons/4/47/Space-cadet.jpg">keyboard used on Symbolics lisp machines</a>. On a PC keyboard one will usually use the Alt key as the Meta key. On a Mac keyboard one will use the Option key. It may be necessary to specify this mapping. In the Preferences of the Mac Terminal App, there is a checkbox under Settings and Keyboard.</p> <p>In this document the notation C-x and M-x are used to denote control and meta modified keystrokes. This is the notation used in Emacs documentation. The nano documentation uses ^X and M-X. The Vim documentation uses CTRL-X and nothing for the meta modified keystrokes which are not used by Vim.</p> <p>On PC and Mac keyboards the control key is in an awkward position. If one is willing to give up CAPS LOCK one can map that key to Control. On Windows make this edit to the registry:</p> <div class="code"> <pre> <code>[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00</code> </pre></div> <p>If the entry does not exist create it with REG_BINARY. A reboot is necessary.</p> <p>On a Mac the remapping can be performed by going to <tt>System Preferences | Keyboard | Modifier Keys …</tt></p> <p>In Emacs, most control and meta modified keys are mapped to commands, but a few are prefixes. Prefixes permit mapping commands to multiple keystroke sequences. The normal prefixes are C-c, C-h, C-x, M-g, M-o, and M-s.</p> <p><strong>mode</strong></p> <p>A set of key bindings. <em>…and also variables which control how text in the buffer is displayed.</em></p> <p>In Emacs the mode is chosen automatically for each buffer when a file is opened for editing or viewing. There is usually no reason to change the mode unless Emacs chose the mode incorrectly.</p> <p>In Vim the user switches between modes frequently during the course of editing a file. The most commonly used modes are normal mode, insert mode, visual mode, and cmdline mode.</p> <p><strong>buffer</strong></p> <p>A buffer is a sequence of characters which editors use to read file contents into memory. A change to a buffer is immediately rendered on screen if the portion of the buffer that was changed is currently visible.</p> <p>Some buffers do not contain the contents of a file. Buffers can be used to display directory contents, help screens, error messages, or shell output.</p> <p>In Emacs if a buffer is not associated with a file, it is given a name containing asterisks, e.g. <tt>*scratch*</tt>.</p> <p>Emacs buffers which contain file contents take their name from the basename of the file. When there are buffer name collisions Emacs appends <1>, <2>, etc. to the ends of the buffer names. The <tt>uniqify</tt> library can change this behavior to use part of the full pathname instead.</p> <p><strong>window</strong></p> <p>The portion of a screen used to display a buffer. In Emacs the <em>mode line</em> and the <em>fringe</em> are considered part of the window.</p> <p>An Emacs window is not synonymous with the windows provided by the GUI that Emacs is running in. Emacs calls GUI windows <em>frames</em>.</p> <p><strong>frame</strong></p> <p>When the editor is running as a GUI application, the frame is the entire canvas provided by the GUI window. When running as a text-mode application in a terminal, the frame is the entire display of the terminal.</p> <p>Vim documentation calls the frame the <em>screen</em>.</p> <p><strong>mode line</strong></p> <p>A line at the bottom of a window with information about the buffer. In Emacs it has the buffer and major mode and minor modes currently in effect.</p> <p><strong>fringe</strong></p> <p>The left and right edge of the window.</p> <p>In Emacs the fringe is used to indicate lines that were wrapped or truncated.</p> <p><strong>visible portion of the buffer</strong></p> <p>The portion of the buffer that is currently displayed in a window. Sometimes we will simply call this portion of the buffer the window.</p> <p><strong>echo area/minibuffer</strong></p> <p>An area at the bottom of the frame which Emacs used to display messages and accept arguments. When it is displaying a message it is called the echo area. When it is accepting an argument it is called the minibuffer. The minibuffer is used to enter a buffer name, a file name, a search term, the full name of an emacs command, a lisp expression, or a shell command.</p> <p>Vim reserves the bottom of the frame for a similar purpose. When a : is typed, one enters command line mode and the line is called the command line. Commands which require an argument such as a file name usually must be entered on the command line. When not in command line mode Vim will sometimes messages on what the documentation calls the "bottom of the screen". Some of these messages are equivalent to information that Emacs would display in the mode line, not echo area.</p> <p><strong>point (cursor)</strong></p> <p>The place in the buffer where characters will be inserted or commands will have effect.</p> <p><strong>mark (the other end of the selection)</strong></p> <p>When of the buffer is being selecting, it is defined by the current location of the point and an entity called the mark which was the location of the point when the selection process was started.</p> <p><strong>pane</strong></p> <p><strong>frame</strong></p> <p>A GUI window owned by the editor when the editor is being run as a GUI application.</p> <p><strong>copy/paste/yank?</strong></p> <p><strong>registers/kill ring</strong></p> <p><strong>face</strong></p> <p><a name="line-editors" id="line-editors"></a></p> <h1 id="toc149"><span><a href="text-mode-editors#top">Line Editors</a></span></h1> <table class="wiki-content-table"> <tr> <th></th> <th>vi</th> <th>ex</th> <th>sed</th> <th>ed</th> </tr> <tr> <td>insert text after current line. Use a line with single period . to exit input mode.</td> <td>o</td> <td>a <span style="color: gray"><em>or</em></span> .a</td> <td></td> <td>a <span style="color: gray"><em>or</em></span> .a</td> </tr> <tr> <td>delete first line</td> <td>:1d</td> <td>1d</td> <td>sed 1d</td> <td>1d</td> </tr> <tr> <td>delete first 10 lines</td> <td>:1,10d</td> <td>1,10d</td> <td>sed 1,10d</td> <td>1,10d</td> </tr> <tr> <td>delete all lines after 10th</td> <td>:11,$d</td> <td>11,$d</td> <td>sed '11,$d'</td> <td>11,$d</td> </tr> <tr> <td>delete current line</td> <td>:d <span style="color: gray"><em>or</em></span> :.d</td> <td>d <span style="color: gray"><em>or</em></span> .d</td> <td></td> <td>d <span style="color: gray"><em>or</em></span> .d</td> </tr> <tr> <td>delete current and all later lines</td> <td>:.,$d</td> <td>.,$d</td> <td></td> <td>.,$d</td> </tr> <tr> <td>switch to editing <span style="color: gray"><em>file</em></span>, but warn if there are unsaved changes</td> <td>:e <span style="color: gray"><em>file</em></span></td> <td>e <span style="color: gray"><em>file</em></span></td> <td></td> <td>e <span style="color: gray"><em>file</em></span></td> </tr> <tr> <td>switch to editing <span style="color: gray"><em>file</em></span> unconditionally</td> <td>:e! <span style="color: gray"><em>file</em></span></td> <td>e! <span style="color: gray"><em>file</em></span></td> <td></td> <td>E <span style="color: gray"><em>file</em></span></td> </tr> <tr> <td>insert text at front of current line. Use a line with a single period . to exit input mode.</td> <td>O</td> <td>i <span style="color: gray"><em>or</em></span> .i</td> <td></td> <td>i <span style="color: gray"><em>or</em></span> .i</td> </tr> <tr> <td>append line 2 to the end of line 1</td> <td>:1,2j</td> <td>1,2j</td> <td></td> <td>1,2j</td> </tr> <tr> <td>append following line to end of current line</td> <td>J</td> <td>j</td> <td></td> <td>j</td> </tr> <tr> <td>print current line number and its contents</td> <td></td> <td></td> <td></td> <td>n <span style="color: gray"><em>or</em></span> .n</td> </tr> <tr> <td>print line numbers for lines 1 thru 10 and their contents. Also move to line 10</td> <td></td> <td></td> <td></td> <td>1,10n</td> </tr> <tr> <td>display line numbers with lines</td> <td>:set nu</td> <td>set nu</td> <td></td> <td></td> </tr> <tr> <td>don't display line numbers with lines</td> <td>:set nu!</td> <td>set nu!</td> <td></td> <td></td> </tr> <tr> <td>print first line and move to it</td> <td></td> <td>1p</td> <td>sed -n 1p</td> <td>1p</td> </tr> <tr> <td>print line 10 and move to it</td> <td></td> <td>10p</td> <td>sed -n 10p</td> <td>10p</td> </tr> <tr> <td>print lines 1,10 and move to line 10</td> <td></td> <td>1,10p</td> <td>sed -n 1,10p</td> <td>1,10p</td> </tr> <tr> <td>quit, but warn if there are unsaved changed</td> <td>:q</td> <td>q</td> <td></td> <td>q</td> </tr> <tr> <td>quit unconditionally</td> <td>:q!</td> <td>q!</td> <td></td> <td>Q</td> </tr> <tr> <td>insert contents of <span style="color: gray"><em>file</em></span> after line 10</td> <td>:10r <span style="color: gray"><em>file</em></span></td> <td>10r <span style="color: gray"><em>file</em></span></td> <td></td> <td>10r <span style="color: gray"><em>file</em></span></td> </tr> <tr> <td>replace first occurrence of foo with bar on first line</td> <td>:1s/foo/bar/</td> <td>1s/foo/bar/</td> <td>sed 1s/foo/bar/</td> <td>1s/foo/bar/</td> </tr> <tr> <td>replace all non-overlapping occurrences of foo with bar on first line</td> <td>:1s/foo/bar/g</td> <td>1s/foo/bar/g</td> <td>sed 1s/foo/bar/g</td> <td>1s/foo/bar/g</td> </tr> <tr> <td>replace foo with bar on first ten lines</td> <td>:1,10s/foo/bar/</td> <td>1,10s/foo/bar/</td> <td>sed 1,10s/foo/bar/</td> <td>1,10s/foo/bar/</td> </tr> <tr> <td>replace foo with bar on current line</td> <td>:s/foo/bar/</td> <td>s/foo/bar/</td> <td></td> <td>s/foo/bar/</td> </tr> <tr> <td>insert a copy lines 1 thru 10 after line 20</td> <td>:1,10t20</td> <td>1,10t20</td> <td></td> <td>1,10t20</td> </tr> <tr> <td>undo; in ed 2nd invocation undoes the first; vim and ex keep history</td> <td>u</td> <td>u</td> <td></td> <td>u</td> </tr> <tr> <td>write all lines to <span style="color: gray"><em>file</em></span></td> <td>:w <span style="color: gray"><em>file</em></span></td> <td>w <span style="color: gray"><em>file</em></span></td> <td></td> <td>w <span style="color: gray"><em>file</em></span></td> </tr> <tr> <td>write lines 1 thru 10 to <span style="color: gray"><em>file</em></span></td> <td>:1,10w <span style="color: gray"><em>file</em></span></td> <td>1,10w <span style="color: gray"><em>file</em></span></td> <td></td> <td>1,10w <span style="color: gray"><em>file</em></span></td> </tr> </table> <p>Vim has a built-in line editor called ex. Editing in ex mode is like running commands in cmdline mode with the colon :. The only difference is that in ex mode one does not return to normal mode after a command finishes.</p> <p>One can switch to the line editor with the command <tt>Q</tt>. Once in the line editor the line editing commands can be issued without the preceding colon. If vim is launched using the name <tt>ex</tt> then it goes immediately into the line editor. The command <tt>vi</tt> switches back to the visual editor.</p> <p>A line editor such as <tt>ex</tt> or <tt>ed</tt> is the only way to edit a file when working in a terminal which does not support redrawing the screen.</p> <p><tt>ed</tt> is the only way to edit files on ancient versions of Unix such as <a href="http://pdp11.aiju.de/">Version 6</a>. <tt>ed</tt> may be the only editor installed in a resource constrained environment: the Ubuntu vim executable is 1.8M and the <tt>ed</tt> executable is 48k.</p> <p>The stream editor <tt>sed</tt> can be used to apply line editing commands to files at the command line.</p> <p><a name="bindings-other-apps" id="bindings-other-apps"></a></p> <h1 id="toc150"><span><a href="text-mode-editors#top">Vim Bindings in Other Applications</a></span></h1> <table class="wiki-content-table"> <tr> <th></th> <th colspan="2">Shells</th> <th>Pagers</th> <th colspan="2">Multiplexer Copy Mode</th> </tr> <tr> <th></th> <th>bash</th> <th>zsh</th> <th>less</th> <th>screen</th> <th>tmux</th> </tr> <tr> <td>page down</td> <td></td> <td></td> <td>C-f</td> <td></td> <td></td> </tr> <tr> <td>page half down</td> <td></td> <td></td> <td>C-d</td> <td></td> <td></td> </tr> <tr> <td>page up</td> <td></td> <td></td> <td>C-b</td> <td></td> <td></td> </tr> </table> <p>This command gives Bash Vim-style bindings when editing a command:</p> <div class="code"> <pre> <code>set -o vi</code> </pre></div> <p>This command gives Zsh Vim-style bindings:</p> <div class="code"> <pre> <code>bindkey -v</code> </pre></div> <h1 id="toc151"><span><a href="text-mode-editors#top">Emacs Bindings in Other Applications</a></span></h1> <table class="wiki-content-table"> <tr> <th></th> <th colspan="2">Shells</th> <th>Pagers</th> <th colspan="2">Multiplexer Copy Mode</th> <th colspan="3">Browser Textareas</th> <th colspan="3">IDEs</th> </tr> <tr> <th></th> <th>Bash</th> <th>Zsh</th> <th>less</th> <th>screen</th> <th>tmux</th> <th>Chrome (Mac)</th> <th>Firefox (Mac)</th> <th>Safari (Mac)</th> <th>Xcode</th> <th>Visual Studio</th> <th>Eclipse (Mac)</th> </tr> <tr> <td>move to beginning of line</td> <td>C-a</td> <td>C-a</td> <td></td> <td></td> <td></td> <td>C-a</td> <td>C-a</td> <td>C-a</td> <td>C-a</td> <td>C-a</td> <td>C-a</td> </tr> <tr> <td>move forward char</td> <td>C-b</td> <td>C-b</td> <td></td> <td></td> <td></td> <td>C-b</td> <td>C-b</td> <td>C-b</td> <td>C-b</td> <td>C-b</td> <td>C-b</td> </tr> <tr> <td>delete forward char</td> <td>C-d</td> <td>C-d</td> <td></td> <td></td> <td></td> <td></td> <td>C-d</td> <td></td> <td></td> <td>C-d</td> <td>C-d</td> </tr> <tr> <td>move to end of line</td> <td>C-e</td> <td>C-e</td> <td></td> <td></td> <td></td> <td>C-e</td> <td>C-e</td> <td>C-e</td> <td>C-e</td> <td>C-e</td> <td>C-e</td> </tr> <tr> <td>move backward char</td> <td>C-f</td> <td>C-f</td> <td></td> <td></td> <td></td> <td>C-f</td> <td>C-f</td> <td>C-f</td> <td>C-f</td> <td>C-f</td> <td>C-f</td> </tr> <tr> <td><span style="color: gray"><em>delete backward char</em></span></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td><span style="color: gray"><em>C-h</em></span></td> <td></td> <td><span style="color: gray"><em>C-h</em></span></td> <td><span style="color: gray"><em>C-h</em></span></td> <td></td> <td></td> </tr> <tr> <td><span style="color: gray"><em>insert tab</em></span></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td><span style="color: gray"><em>C-i</em></span></td> <td></td> <td><span style="color: gray"><em>C-i</em></span></td> <td></td> <td></td> <td></td> </tr> <tr> <td>delete to end of line</td> <td>C-k</td> <td>C-k</td> <td></td> <td></td> <td></td> <td>C-k</td> <td>C-k</td> <td>C-k</td> <td>C-k</td> <td>C-k</td> <td>C-k</td> </tr> <tr> <td>move to next line</td> <td></td> <td></td> <td>C-n</td> <td></td> <td></td> <td>C-n</td> <td>C-n</td> <td>C-n</td> <td>C-n</td> <td>C-n</td> <td>C-n</td> </tr> <tr> <td>open line</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>C-o</td> <td></td> <td>C-o</td> <td>C-o</td> <td>C-o</td> <td></td> </tr> <tr> <td>move to previous line</td> <td></td> <td></td> <td>C-p</td> <td></td> <td></td> <td>C-p</td> <td>C-p</td> <td>C-p</td> <td>C-p</td> <td>C-p</td> <td>C-p</td> </tr> <tr> <td>reverse search <span style="color: gray"><em>of command history</em></span></td> <td></td> <td>C-r</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><span style="color: gray"><em>submit form</em></span></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td><span style="color: gray"><em>C-s</em></span></td> <td></td> <td><span style="color: gray"><em>C-s</em></span></td> <td></td> <td></td> <td></td> </tr> <tr> <td>transpose characters</td> <td>C-t</td> <td>C-t</td> <td></td> <td></td> <td></td> <td>C-t</td> <td></td> <td>C-t</td> <td>C-t</td> <td>C-t</td> <td></td> </tr> <tr> <td>page down</td> <td></td> <td></td> <td>C-v</td> <td></td> <td></td> <td>C-v</td> <td></td> <td>C-v</td> <td>C-v</td> <td>C-v</td> <td>C-v</td> </tr> <tr> <td>page up</td> <td></td> <td></td> <td>M-v</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>M-v</td> <td>M-v</td> </tr> <tr> <td>yank</td> <td>C-y</td> <td>C-y</td> <td></td> <td></td> <td></td> <td>C-y</td> <td></td> <td>C-y</td> <td>C-y</td> <td>C-y</td> <td>C-y</td> </tr> <tr> <td>move backward word</td> <td>M-b</td> <td>M-b</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>M-b</td> <td>M-b</td> </tr> <tr> <td>move forward word</td> <td>M-f</td> <td>M-f</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>M-f</td> <td>M-f</td> </tr> <tr> <td>delete backward char</td> <td>DEL</td> <td>DEL</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>DEL</td> <td>DEL</td> </tr> <tr> <td>delete backward word</td> <td>M-DEL</td> <td>M-DEL</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>M-DEL</td> <td>M-DEL</td> </tr> <tr> <td>delete forward word</td> <td>M-d</td> <td>M-d</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>M-d</td> <td>M-d</td> </tr> </table> <p>To get Emacs style bindings in Visual Studio, one must go to the <tt>Tools | Options… | Environment | Keyboard</tt> section and set the additional keyboard mapping scheme to Emacs.</p> <p>To get Emacs style bindings in Eclipse, one must go to <tt>Preferences | General | Keys</tt> and set the Scheme to Emacs.</p> </div> </div> </div> <div id="license-area" class="license-area"> <a href="https://github.com/clarkgrubb/hyperpolyglot/issues">issue tracker</a> | content of this page licensed under <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"> creative commons attribution-sharealike 3.0</a> <br> </div> </div> </div> </div> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-17129977-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </body> </html>