<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>Challenge everything! &#187; Vim</title>
	<atom:link href="http://blogs.gnome.org/raywang/category/free-software/vim/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.gnome.org/raywang</link>
	<description>Ray Wang&#039;s notes</description>
	<lastBuildDate>Mon, 30 May 2011 03:11:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/</creativeCommons:license>		<item>
		<title>我的~/.vimrc 保存下来作为备份</title>
		<link>http://blogs.gnome.org/raywang/2008/06/16/%e6%88%91%e7%9a%84vimrc-%e4%bf%9d%e5%ad%98%e4%b8%8b%e6%9d%a5%e4%bd%9c%e4%b8%ba%e5%a4%87%e4%bb%bd/</link>
		<comments>http://blogs.gnome.org/raywang/2008/06/16/%e6%88%91%e7%9a%84vimrc-%e4%bf%9d%e5%ad%98%e4%b8%8b%e6%9d%a5%e4%bd%9c%e4%b8%ba%e5%a4%87%e4%bb%bd/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 08:59:00 +0000</pubDate>
		<dc:creator>raywang</dc:creator>
				<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://raywang.yo2.cn/articles/%e6%88%91%e7%9a%84vimrc-%e4%bf%9d%e5%ad%98%e4%b8%8b%e6%9d%a5%e4%bd%9c%e4%b8%ba%e5%a4%87%e4%bb%bd.html</guid>
		<description><![CDATA[&#60;br&#62; <a href="http://blogs.gnome.org/raywang/2008/06/16/%e6%88%91%e7%9a%84vimrc-%e4%bf%9d%e5%ad%98%e4%b8%8b%e6%9d%a5%e4%bd%9c%e4%b8%ba%e5%a4%87%e4%bb%bd/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;<br />
&quot; General<br />
&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;<br />
filetype on&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &quot; detect the type of file<br />
filetype plugin on  &quot; load filetype plugins</p>
<p>&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;<br />
&quot; Theme/Colors<br />
&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;<br />
syntax on&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &quot; syntax highlighting on<br />
colorscheme ron&nbsp;&nbsp;&nbsp;&nbsp;  &quot; colorscheme for black background</p>
<p>&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;<br />
&quot; Visual Cues<br />
&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;<br />
set showmatch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &quot; show matching brackets<br />
set hlsearch<br />
set incsearch</p>
<p>&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;<br />
&quot; Text Formatting/Layout<br />
&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;<br />
set autoindent<br />
set smartindent <br />
set formatoptions=tcqrmM1<br />
&quot;give a indent when typing &#8216;#&#8217;<br />
inoremap # X #<br />
set tabstop=4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &quot; TAB means 4 spaces<br />
set shiftwidth=4&nbsp;&nbsp;&nbsp;  &quot; <br />
set expandtab&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &quot; replace TAB by SPACE</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/raywang/2008/06/16/%e6%88%91%e7%9a%84vimrc-%e4%bf%9d%e5%ad%98%e4%b8%8b%e6%9d%a5%e4%bd%9c%e4%b8%ba%e5%a4%87%e4%bb%bd/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>vim进阶</title>
		<link>http://blogs.gnome.org/raywang/2007/10/22/vim%e8%bf%9b%e9%98%b6/</link>
		<comments>http://blogs.gnome.org/raywang/2007/10/22/vim%e8%bf%9b%e9%98%b6/#comments</comments>
		<pubDate>Mon, 22 Oct 2007 12:35:00 +0000</pubDate>
		<dc:creator>raywang</dc:creator>
				<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://raywang.yo2.cn/articles/vim%e8%bf%9b%e9%98%b6.html</guid>
		<description><![CDATA[&#60;br&#62; <a href="http://blogs.gnome.org/raywang/2007/10/22/vim%e8%bf%9b%e9%98%b6/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>从好朋友cocobear那里引的有关vim使用的文章，我觉得有必要改下来，以后有时间再学习学习<br />
http://cocobear.cn/blog/2007/09/30/vim%e8%bf%9b%e9%98%b6/</p>
<p>*摘自：http://edt1023.sayya.org/vim/index.html<br />
  *<br />
  *里面有很多非常好用的我用蓝色标记了一下，看看你都知道这些好用的功能吗？<br />
 *<br />
 */</p>
<p>Ctrl+f  即 PageDown 翻頁（Forward，向前、下翻頁）。<br />
Crtl+b  即 PageUp 翻頁（Backward，向後、上翻頁)。</p>
<p>0       是數目字 0 而不是英文字母 o。移至行首，（含空白字元）。<br />
W       移动一个符，但會忽略一些標點符號。<br />
e       移至後一個字字尾。<br />
E       同上，但會忽略一些標點符號。<br />
b       移至前一個字字首。<br />
B       同上，但會忽略一些標點符號。<br />
H       移至螢幕頂第一個非空白字元。<br />
M       移至螢幕中間第一個非空白字元。<br />
L       移至螢幕底第一個非空白字元。</p>
<p>)       移至下一個句子（sentence）首。<br />
(       移至上一個句子（sentence）首。sentence（句子）是以 . ! ? 為區格。<br />
}       移至下一個段落（paragraph）首。<br />
{       移至上一個段落（paragraph）首。paragraph（段落）是以空白行為區格。</p>
<p>R进入替换模式</p>
<p>I       在行首開始輸入文字。此之行首指第一個非空白字元處，要從真正的第一個字元處開始輸人文字，可使用 0i 或 gI(Vim 才有)。<br />
A       在行尾開始輸入文字。這個好用，您不必管游標在此行的什麼地方，只要按 A 就會在行尾等著您輸入文字。<br />
O       在游標所在行上開一新行來輸入文字。<br />
J       將下一行整行接至本行(Joint)。</p>
<p>dG      刪至檔尾。<br />
d1G     刪至檔首。或 dgg(只能用於 Vim)。<br />
D       刪至行尾，或 d$（含游標所在處字元）。<br />
d0      刪至行首，或 d^（不含游標所在處字元）。請回憶一下 $ 及 ^ 所代表的意義，您就可以理解 d$ 及 d^ 的動作，這就是 vi(m) 可愛之處。</p>
<p>5J      將五行合併成一行。<br />
5i A    然後按 Ecs，插入五個 A。中文也可以！<br />
2i sys Esc      插入 syssys。中文也可以！</p>
<p><font color="lightblue">:ce(nter) 本行文字置中。注意是冒號命令！<br />
:ri(ght)        本行文字靠右。<br />
:le(ft) 本行文字靠左。所謂置中、靠左右，是參考 textwidth(tw) 的設定。如果 tw 沒有設定，預設是80，就是以 80 個字元為總寬度為標準來置放。當然您也可以如 sw 一樣馬上重設。</font><br />
gqap    整段重排，或 gqip，在段落中位何地方都可以使用。和中文的配合見下述。<br />
gqq     本行重排。<br />
gqG     全文重排，是以游標所在處的段落開始重排至檔尾。以空白行為段落的間隔。</p>
<p><font color="lightblue">&raquo; 整行向右移一個 shiftwidth（預設是 8 個字元，可重設）。这个好啊，写代码时缩进就方便了。<br />
&laquo;       整行向左移一個 shiftwidth（預設是 8 個字元，可重設）。</font></p>
<p>:[range]s/pattern/string/[c,e,g,i]5.1<br />
range   指的是範圍，1,7 指從第一行至第七行，1,$ 指從第一行至最後一行，也就是整篇文章，也可以 % 代表。還記得嗎？ % 是目前編輯的文章，# 是前一次編輯的文章。<br />
pattern 就是要被替換掉的字串，可以用 regexp 來表示。<br />
string  將 pattern 由 string 所取代。<br />
c       confirm，每次替換前會詢問。<br />
e       不顯示 error。<br />
g       globe，不詢問，整行替換。<br />
i       ignore 不分大小寫。</p>
<p><font color="lightblue">mx        x 代表 26 個小寫英文字母，這樣游標所在處就會被 mark。</font><br />
`x      回到書籤原設定位置。` 是 backward quote，就是 Tab 鍵上面那一個。<br />
&lsquo;x      回到書籤設定行行首。&rsquo; 是 forward quote，是 Enter 鍵隔壁那一個。</p>
<p><font color="lightblue"># 或 Ctrl+^       編輯前一個檔案，用於兩檔互相編輯時相當好用。這種用法不管是 argument list 或 buffer list 檔案間皆可使用。還記得嗎？# 代表的是前一次編輯的檔案。</font></p>
<p>:f 或 Ctrl+g    顯示目前編輯的檔名、是否經過修改及目前游標所在之位置。<br />
:f 檔名 改變編輯中的檔名。(file)<br />
<font color="lightblue">:r 檔名   在游標所在處插入一個檔案內容。(read)</font></p>
<p><font color="lightblue">vim -x [檔名] 加密编辑一个文件，每次编辑时要求输入密码，否则为乱码。也可以在编辑时使用:X命令来设置密码，不过要注意，设置以后需要保存并退出。</font></p>
<p>Ctrl+w n        即 :new。開一空的新視窗。<br />
Ctrl+w s        即 :sp(lit)，會開一新視窗，且原檔分屬兩個視窗。<br />
Ctrl+w f        開一新視窗，並編輯游標所在處之 word 為檔名的檔案。<br />
Ctrl+w q        即 :q 結束分割出來的視窗。<br />
Ctrl+w o        即 <img src='http://blogs.gnome.org/raywang/wp-content/mu-plugins/tango-smilies/tango/face-surprise.png' alt=':o' class='wp-smiley' /> nly! 使游標所在之視窗，成為目前唯一顯示的視窗其它視窗會隱藏起來。<br />
Ctrl+w j        移至下視窗。<br />
Ctrl+w k        移至上視窗。還記得 hjkl 的按鍵移動方式嗎？</p>
<p>:sh(ell)        執行 shell。使用 exit 回到 vim。<br />
<font color="lightblue">:r !commond       這個就妙了！會在游標所在處次一行插入外部指令 commond 執行後的輸出內容。例如 :r !date 就會插入日期時間。這在 elvis 是會插入在游標所在處那一行。</font><br />
:n,mw !commond  以 n 至 m 行內之資料，當做外部指令 commond 的 input。這算是相當高級的用法了，初學者大概還用不上，不過印象中留有一個這樣的功能，以後總是會用得上的。<br />
<font color="lightblue">K 大寫 K 會顯示游標所在處之 word 的 man page 系統線上使用手冊。</font></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/raywang/2007/10/22/vim%e8%bf%9b%e9%98%b6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>改变vim中多窗口的大小</title>
		<link>http://blogs.gnome.org/raywang/2007/05/24/%e6%94%b9%e5%8f%98vim%e4%b8%ad%e5%a4%9a%e7%aa%97%e5%8f%a3%e7%9a%84%e5%a4%a7%e5%b0%8f/</link>
		<comments>http://blogs.gnome.org/raywang/2007/05/24/%e6%94%b9%e5%8f%98vim%e4%b8%ad%e5%a4%9a%e7%aa%97%e5%8f%a3%e7%9a%84%e5%a4%a7%e5%b0%8f/#comments</comments>
		<pubDate>Thu, 24 May 2007 02:02:00 +0000</pubDate>
		<dc:creator>raywang</dc:creator>
				<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://raywang.yo2.cn/articles/%e6%94%b9%e5%8f%98vim%e4%b8%ad%e5%a4%9a%e7%aa%97%e5%8f%a3%e7%9a%84%e5%a4%a7%e5%b0%8f.html</guid>
		<description><![CDATA[&#60;br&#62; <a href="http://blogs.gnome.org/raywang/2007/05/24/%e6%94%b9%e5%8f%98vim%e4%b8%ad%e5%a4%9a%e7%aa%97%e5%8f%a3%e7%9a%84%e5%a4%a7%e5%b0%8f/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h4>http://vcd.gro.clinux.org/doc/windows.html#window-resize</h4>
<h4>6. 改变窗口大小                                         <strong>*<a name="window-resize">window-resize</a>*</strong></h4>
<p>                                                <strong>*<a name="CTRL-W_ ">CTRL-W_=</a>*</strong><br /><code>CTRL-W</code> =        使得所有窗口 (几乎) 等宽、等高，但当前窗口使用 &#8216;winheight&#8217; 和<br />                &#8216;winwidth&#8217;。</p>
<p>:res[ize] -N                                    <strong>*<a name=":res">:res</a>*</strong> <strong>*<a name=":resize">:resize</a>*</strong> <strong>*<a name="CTRL-W_-">CTRL-W_-</a>*</strong><br /><code>CTRL-W</code> &#8211;        使得当前窗口高度减 N (默认值是 1)。<br />                如果在 &#8216;vertical&#8217; 之后使用，则使得宽度减 N。</p>
<p>:res[ize] +N                                    <strong>*<a name="CTRL-W_+">CTRL-W_+</a>*</strong><br /><code>CTRL-W</code> +        使得当前窗口高度加 N (默认值是 1)。<br />                如果在 &#8216;vertical&#8217; 之后使用，则使得宽度加 N。</p>
<p>:res[ize] [N]<br /><code>CTRL-W</code> <code>CTRL-_</code>                                   <strong>*<a name="CTRL-W_CTRL-_">CTRL-W_CTRL-_</a>*</strong> <strong>*<a name="CTRL-W__">CTRL-W__</a>*</strong><br /><code>CTRL-W</code> _        设置当前窗口的高度为 N (默认值为最大可能高度)。</p>
<p>z<code>{nr}</code><code>&lt;CR&gt;</code>       设置当前窗口的高度为 <code>{nr}</code>。</p>
<p>                                                <strong>*<a name="CTRL-W_&lt;">CTRL-W_&lt;</a>*</strong><br /><code>CTRL-W</code> &lt;        使得当前窗口宽度减 N (默认值是 1)。</p>
<p>                                                <strong>*<a name="CTRL-W_&gt;">CTRL-W_&gt;</a>*</strong><br /><code>CTRL-W</code> &gt;        使得当前窗口宽度加 N (默认值是 1)。</p>
<p>:vertical res[ize] [N]                  <strong>*<a name=":vertical-resize">:vertical-resize</a>*</strong> <strong>*<a name="CTRL-W_bar">CTRL-W_bar</a>*</strong><br /><code>CTRL-W</code> |        设置当前窗口的宽度为 N (默认值为最大可能宽度)。</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/raywang/2007/05/24/%e6%94%b9%e5%8f%98vim%e4%b8%ad%e5%a4%9a%e7%aa%97%e5%8f%a3%e7%9a%84%e5%a4%a7%e5%b0%8f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vim 茶杯</title>
		<link>http://blogs.gnome.org/raywang/2007/04/30/vim-%e8%8c%b6%e6%9d%af/</link>
		<comments>http://blogs.gnome.org/raywang/2007/04/30/vim-%e8%8c%b6%e6%9d%af/#comments</comments>
		<pubDate>Mon, 30 Apr 2007 01:59:00 +0000</pubDate>
		<dc:creator>raywang</dc:creator>
				<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://raywang.yo2.cn/articles/vim-%e8%8c%b6%e6%9d%af.html</guid>
		<description><![CDATA[&#60;br&#62; <a href="http://blogs.gnome.org/raywang/2007/04/30/vim-%e8%8c%b6%e6%9d%af/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>http://feeds.feedburner.com/~r/linuxtoy/~3/112854086/the-mug-of-vi.html</p>
<p>有图可以印在荼杯上</p>
<div><a target="_blank" href="http://hiphotos.baidu.com/dream1123/pic/item/e35738db6856f662d1164e28.jpg"><img border="0" class="blogimg" src="http://hiphotos.baidu.com/dream1123/abpic/item/e35738db6856f662d1164e28.jpg"></a></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/raywang/2007/04/30/vim-%e8%8c%b6%e6%9d%af/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>高效率编辑器 VIM－操作篇，非常适合 VIM 新手</title>
		<link>http://blogs.gnome.org/raywang/2007/01/29/%e9%ab%98%e6%95%88%e7%8e%87%e7%bc%96%e8%be%91%e5%99%a8-vim%ef%bc%8d%e6%93%8d%e4%bd%9c%e7%af%87%ef%bc%8c%e9%9d%9e%e5%b8%b8%e9%80%82%e5%90%88-vim-%e6%96%b0%e6%89%8b/</link>
		<comments>http://blogs.gnome.org/raywang/2007/01/29/%e9%ab%98%e6%95%88%e7%8e%87%e7%bc%96%e8%be%91%e5%99%a8-vim%ef%bc%8d%e6%93%8d%e4%bd%9c%e7%af%87%ef%bc%8c%e9%9d%9e%e5%b8%b8%e9%80%82%e5%90%88-vim-%e6%96%b0%e6%89%8b/#comments</comments>
		<pubDate>Mon, 29 Jan 2007 01:41:00 +0000</pubDate>
		<dc:creator>raywang</dc:creator>
				<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://raywang.yo2.cn/articles/%e9%ab%98%e6%95%88%e7%8e%87%e7%bc%96%e8%be%91%e5%99%a8-vim%ef%bc%8d%e6%93%8d%e4%bd%9c%e7%af%87%ef%bc%8c%e9%9d%9e%e5%b8%b8%e9%80%82%e5%90%88-vim-%e6%96%b0%e6%89%8b.html</guid>
		<description><![CDATA[&#60;br&#62; <a href="http://blogs.gnome.org/raywang/2007/01/29/%e9%ab%98%e6%95%88%e7%8e%87%e7%bc%96%e8%be%91%e5%99%a8-vim%ef%bc%8d%e6%93%8d%e4%bd%9c%e7%af%87%ef%bc%8c%e9%9d%9e%e5%b8%b8%e9%80%82%e5%90%88-vim-%e6%96%b0%e6%89%8b/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><font size="2">转自：http://linuxtoy.org/archives/efficient-editing-with-vim.html</font></p>
<p><font size="2"><br />
</font></p>
<p><font size="2">虽然从很久前就开始用 VIM 了，但一直都是半<del datetime="2007-01-27T13:01:01+00:00">调</del>吊 子，翻来覆去只用自己会的命令。最近为了提高书写代码的效率，还有 coding 时候的乐趣，又重新钻研了一下 VIM，发现了一篇很好的 VIM 入门的文章，原文是英文版的，我觉得非常适合 VIM 使用入门，所以翻译了过来。这里是简单的介绍了 VIM 的操作方式，并没有说为什么要用 VIM，如果你想知道答案可以去 Google，VIM 被誉为编辑器之神。</font></p>
<p><font size="2">这篇教程写了在不同工作模式下使用 VIM 的一些基本技巧&mdash;&mdash;即插入模式（insert mode）， 命令模式（command mode）， 存取文件等。目的是帮助刚刚接触 VIM 的新手更加有效率的使用这个出色的编辑器。</font></p>
<p><font size="2">说明：在这篇文章里面，&lt;C-X&gt; 代表 Ctrl + X&mdash;&mdash;就是按住 Ctrl 键然后再按 X。而且你可以在很多情况下使用 :help command 来获得大部分命令的帮助，这个是 VIM 的内部帮助文件命令。</font></p>
<p><font size="2"><strong>高效率移动</strong></font></p>
<p><font size="2"><em>在插入模式之外</em></font></p>
<p><font size="2">基本上来说，你应该尽可能少的呆在插入模式里面，因为在插入模式里面 VIM 就像一个&ldquo;哑巴&rdquo;编辑器一样。很多新手都会一直呆在插入模式里面，因为这样易于使用。但 VIM 的强大之处在于他的命令行模式！你会发现，在你越来越了解 VIM 之后，你就会花越来越少的时间使用插入模式了。</font></p>
<p><font size="2"><em>使用 h、j、k、l</em></font></p>
<p><font size="2">使用 VIM 高效率编辑的第一步，就是放弃使用箭头键。使用 VIM，你就不用频繁的在箭头键和字母键之间移来移去了，这会节省你很多时间。当你在命令模式时，你可以用 h、j、k、l 来分别实现左、下、上、右箭头的功能。一开始可能需要适应一下，但一旦习惯这种方式，你就会发现这样操作的高效之处了。</font></p>
<p><font size="2">在你编辑你的电子邮件或者其他有段落的文本时，你可能会发现使用方向键和你预期的效果不一样，有时候可能会一次跳过了很多行。这是因为你的段落在 VIM 看来是一个大的长长的行。这时你可以在按 h、j、k 或者 l 之前键入一个 g，这样 VIM 就会按屏幕上面的行如你所愿的移动了。</font></p>
<p><font size="2"><em>在当前行里面有效的移动光标</em></font></p>
<p><font size="2">很多编辑器只提供了简单的命令来控制光标的移动（比如左、上、右、下、到行首/尾等）。VIM 则提供了很多强大的命令来满足你控制光标的欲望。当光标从一点移动到另外一点，在这两点之间的文本（包括这两个点）称作被&ldquo;跨过&rdquo;，这里的命令也被称作是 motion。（简单说明一下，后面会用到这个重要的概念）</font></p>
<p><font size="2">这里是常用到的一些命令（motion）：</font></p>
<ul>
<li><font size="2">fx：移动光标到当前行的下一个 x 处。很明显，x 可以是任意一个字母，而且你可以使用 ; 来重复你的上一个 f 命令。</font></li>
<li><font size="2">tx：和上面的命令类似，但是是移动到 x 的左边一个位置。（这真的很有用）</font></li>
<li><font size="2">Fx：和 fx 类似，不过是往回找。</font></li>
<li><font size="2">w：光标往前移动一个词。</font></li>
<li><font size="2">b：光标往后移动一个词。</font></li>
<li><font size="2">0：移动光标到当前行首。</font></li>
<li><font size="2">^：移动光标到当前行的第一个字母位置。</font></li>
<li><font size="2">$：移动光标到行尾。</font></li>
<li><font size="2">)：移动光标到下一个句子。</font></li>
<li><font size="2">( ：移动光标到上一个句子。</font></li>
</ul>
<p><font size="2"><em>在整个文件里面有效移动光标</em></font></p>
<p><font size="2">VIM 有很多命令，可以用来到达文件里面你想到达的地方。下面是一些在文件里面移动的命令：</font></p>
<ul>
<li><font size="2">&lt;C-F&gt;：向下移动一屏。</font></li>
<li><font size="2">&lt;C-B&gt;：向上移动一屏。</font></li>
<li><font size="2">G：到文件尾</font></li>
<li><font size="2">numG：移动光标到指定的行（num）。（比如 10G 就是到第 10 行）</font></li>
<li><font size="2">gg：到文件首</font></li>
<li><font size="2">H：移动光标到屏幕上面</font></li>
<li><font size="2">M：移动光标到屏幕中间</font></li>
<li><font size="2">L：移动光标到屏幕下面</font></li>
<li><font size="2">*：读取光标处的字符串，并且移动光标到它再次出现的地方。</font></li>
<li><font size="2">#：和上面的类似，但是是往反方向寻找。</font></li>
<li><font size="2">/text：从当前光标处开始搜索字符串 text，并且到达 text 出现的地方。必须使用回车来开始这个搜索命令。如果想重复上次的搜索的话，按 n。</font></li>
<li><font size="2">？text：和上面类似，但是是反方向。</font></li>
<li><font size="2">ma：在当前光标的位置标记一个书签，名字为 a。书签名只能是小写字母。你看不见书签的存在，但它确实已经在那里了。</font></li>
<li><font size="2">`a：到书签 a 处。注意这个不是单引号，它一般位于大部分键盘的 1 的左边。</font></li>
<li><font size="2">`.：到你上次编辑文件的地方。这个命令很有用，而且你不用自己去标记它。</font></li>
</ul>
<p><font size="2"><strong>高效的输入</strong></font></p>
<p><font size="2"><em>使用关键词自动完成</em></font></p>
<p><font size="2">VIM 有一个非常漂亮的关键词自动完成系统。这表示，你可以输入一个长词的一部分，然后按一下某个键，然后 VIM 就替你完成了这个长词的输入了。举个例子：你有一个变量名为 iAmALongAndAwkwardVarName 在你写的代码的某个地方。也许你不想每回都自己一个一个字母的去输入它。</font></p>
<p><font size="2">使用关键词自动完成功能，你只需要输入开始几个字母（比如 iAmAL），然后按 &lt;C-N&gt;（按住 Ctrl，再按 N）或者 &lt;C-P&gt;。如果 VIM 没有给出你想要的词，继续按，直到你满意为止，VIM 会一直循环它找到的匹配的字符串。</font></p>
<p><font size="2"><em>聪明的进入插入模式</em></font></p>
<p><font size="2">很多新手进入插入模式都只是用 i。这样当然可以进入插入模式，但通常不是那么合适，因为 VIM 提供了很多进入插入模式的命令。下面是最常用的一些：</font></p>
<ul>
<li><font size="2">i：在当前字符的左边插入</font></li>
<li><font size="2">I：在当前行首插入</font></li>
<li><font size="2">a：在当前字符的右边插入</font></li>
<li><font size="2">A：在当前行尾插入</font></li>
<li><font size="2">o：在当前行下面插入一个新行</font></li>
<li><font size="2">O：在当前行上面插入一个新行</font></li>
<li><font size="2">c{motion}：删除 motion 命令跨过的字符，并且进入插入模式。比如：c$，这将会删除从光标位置到行尾的字符并且进入插入模式。ct！，这会删除从光标位置到下一个叹号（但不包 括），然后进入插入模式。被删除的字符被存在了剪贴板里面，并且可以再粘贴出来。</font></li>
<li><font size="2">d{motion}：和上面差不多，但是不进入插入模式。</font></li>
</ul>
<p><font size="2"><strong>有效的移动大段的文本</strong></font></p>
<p><font size="2"><em>使用可视选择（visual selections）和合适的选择模式</em></font></p>
<p><font size="2">不像最初的 VI，VIM 允许你高亮（选择）一些文本，并且进行操作。这里有三种可视选择模式：</font></p>
<ul>
<li><font size="2">v：按字符选择。经常使用的模式，所以亲自尝试一下它。</font></li>
<li><font size="2">V：按行选择。这在你想拷贝或者移动很多行的文本的时候特别有用。</font></li>
<li><font size="2">&lt;C-V&gt;：按块选择。非常强大，只在很少的编辑器中才有这样的功能。你可以选择一个矩形块，并且在这个矩形里面的文本会被高亮。</font></li>
</ul>
<p><font size="2">在选择模式的时候使用上面所述的方向键和命令（motion）。比如，vwww，会高亮光标前面的三个词。Vjj 将会高亮当前行以及下面两行。</font></p>
<p><font size="2"><em>在可视选择模式下剪切和拷贝</em></font></p>
<p><font size="2">一旦你高亮了选区，你或许想进行一些操作：</font></p>
<ul>
<li><font size="2">d：剪贴选择的内容到剪贴板。</font></li>
<li><font size="2">y：拷贝选择的内容到剪贴板。</font></li>
<li><font size="2">c：剪贴选择的内容到剪贴板并且进入插入模式。</font></li>
</ul>
<p><font size="2"><em>在非可视选择模式下剪切和拷贝</em></font></p>
<p><font size="2">如果你很清楚的知道你想拷贝或者剪切什么，那你根本就不需要进入可视选择模式。这样也会节省时间：</font></p>
<ul>
<li><font size="2">d{motion}：剪切 motion 命令跨过的字符到剪贴板。比如，dw 会剪切一个词而 dfS 会将从当前光标到下一个 S 之间的字符剪切至剪贴板。</font></li>
<li><font size="2">y{motion}：和上面类似，不过是拷贝。</font></li>
<li><font size="2">c{motion}：和 d{motion} 类似，不过最后进入插入模式。</font></li>
<li><font size="2">dd：剪切当前行。</font></li>
<li><font size="2">yy：拷贝当前行。</font></li>
<li><font size="2">cc：剪切当前行并且进入插入模式。</font></li>
<li><font size="2">D：剪切从光标位置到行尾到剪贴板。</font></li>
<li><font size="2">Y：拷贝当前行。</font></li>
<li><font size="2">C：和 D 类似，最后进入插入模式。</font></li>
<li><font size="2">x：剪切当前字符到剪贴板。</font></li>
<li><font size="2">s：和x类似，不过最后进入插入模式。</font></li>
</ul>
<p><font size="2"><em>粘贴</em></font></p>
<p><font size="2">粘贴很简单，按 p。</font></p>
<p><font size="2"><em>使用多重剪贴板</em></font></p>
<p><font size="2">很多编辑器都只提供了一个剪贴板。VIM 有很多。剪贴板在 VIM 里面被称为寄存器（Registers）。你可以列出当前定义的所有寄存器名和它们的内容，命令为&ldquo;:reg&rdquo;。最好使用小写字母来作为寄存器的名称，因为大写的有些被 VIM 占用了。</font></p>
<p><font size="2">使用寄存器的命令为双引号 &ldquo;。</font></p>
<p><font size="2">比如：我们要拷贝当前行到寄存器 k。你应该按 &ldquo;kyy。（你也可以使用 V&rdquo;ky。为什么这样也可以呢？）现在当前行应该已经存在了寄存器 k 里面直到你又拷贝了一些东西进入寄存器 k。现在你可以使用命令 &ldquo;kp 来粘贴寄存器 k 里面的内容到你想要的位置。</font></p>
<p><font size="2"><strong>避免重复</strong></font></p>
<p><font size="2"><em>令人惊奇的 . 命令</em></font></p>
<p><font size="2">在 VI 里面，输入 . (小数点符号），将会重复你输入的上一个命令。比如，你上个命令为&ldquo;dw&rdquo;（删除一个词），VI 将会接着再删除一个词。</font></p>
<p><font size="2"><em>使用数字</em></font></p>
<p><font size="2">使用数字也是 VIM 强大的而且很节省时间的重要特性之一。在很多 VIM 的命令之前都可以使用一个数字，这个数字将会告诉 VIM 这个命令需要执行几次。比如：</font></p>
<ul>
<li><font size="2">3j 将会把光标向下移动三行。</font></li>
<li><font size="2">10dd 将会删除十行。</font></li>
<li><font size="2">y3&Prime; 将会拷贝从当前光标到第三个出现的引号之间的内容到剪贴板。</font></li>
</ul>
<p><font size="2">数字是扩展 motion 命令作用域非常有效的方法。</font></p>
<p><font size="2"><em>记录宏</em></font></p>
<p><font size="2">有时候，你会发现你自己在文章的每段或者每行都重复相同的一系列动作。VIM 允许你记录一个宏来完成你的特殊需要。</font></p>
<ul>
<li><font size="2">qregister：记录宏到寄存器 register，这里 register 是任意的你的寄存器的名字。比如 qa，将会记录并且把宏存在寄存器 a 里面。</font></li>
<li><font size="2">q：结束宏的记录。</font></li>
<li><font size="2">@register：使用存在寄存器 register 的宏。比如 @a，将会使用存在寄存器 a 里面的宏。</font></li>
</ul>
<p><font size="2">必须要记住的是，宏只记录了你的系列按键并且重复执行它们。它们不是魔法。因为在 VIM 里面完成目的的方法有很多，所以有时候你要小心选择命令来记录你的宏。因为它们会在所有你要执行它的地方执行。</font></p>
<p><strong><font size="2">Undo与Redo</font></strong></p>
<p><font size="2">u: undo</font></p>
<p><font size="2">&lt;C-R&gt;: redo</font>
</p>
<p><font size="2"><strong>用 VIM 写代码</strong></font></p>
<p><font size="2">VIM 是一个用来写代码的绝好编辑器，因为它有一些特性是专门为程序员而设计的。这里是一些常用的：</font></p>
<ul>
<li><font size="2">]p：和 p 的功能差不多，但是它会自动调整被粘贴的文本的缩进去适应当前代码的位置。试一下！</font></li>
<li><font size="2">%：匹配花括号、方括号、括号等。在一个括号的上面，然后按 %，鼠标就会出现在匹配的另外一半括号处。</font></li>
<li><font size="2">&gt;&gt;：缩进所有选择的代码</font></li>
<li><font size="2">&lt;&lt;：和上面类似，但是反缩进</font></li>
<li><font size="2">gd：到达光标所在处函数或者变量的定义处。</font></li>
<li><font size="2">K：在 Man 里面查找光标当前所在处的词。 </font></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/raywang/2007/01/29/%e9%ab%98%e6%95%88%e7%8e%87%e7%bc%96%e8%be%91%e5%99%a8-vim%ef%bc%8d%e6%93%8d%e4%bd%9c%e7%af%87%ef%bc%8c%e9%9d%9e%e5%b8%b8%e9%80%82%e5%90%88-vim-%e6%96%b0%e6%89%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vim 键盘图</title>
		<link>http://blogs.gnome.org/raywang/2007/01/25/vim-%e9%94%ae%e7%9b%98%e5%9b%be/</link>
		<comments>http://blogs.gnome.org/raywang/2007/01/25/vim-%e9%94%ae%e7%9b%98%e5%9b%be/#comments</comments>
		<pubDate>Thu, 25 Jan 2007 05:57:00 +0000</pubDate>
		<dc:creator>raywang</dc:creator>
				<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://raywang.yo2.cn/articles/vim-%e9%94%ae%e7%9b%98%e5%9b%be.html</guid>
		<description><![CDATA[&#60;br&#62; <a href="http://blogs.gnome.org/raywang/2007/01/25/vim-%e9%94%ae%e7%9b%98%e5%9b%be/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><font size="2"><span>中文，英文对照<br />
原帖：http://www.linuxsir.org/bbs/showthread.php?t=257834</p>
<div>
<div><a target="_blank" href="http://hiphotos.baidu.com/dream1123/pic/item/6eaf8644c550de4d500ffe22.jpg"><img border="0" class="blogimg" src="http://hiphotos.baidu.com/dream1123/abpic/item/6eaf8644c550de4d500ffe22.jpg"></a></div>
<div><a target="_blank" href="http://lh6.google.com/image/wanglei1123/RbhFbSUMdZI/AAAAAAAAACs/xB5rdh0oU00/vim-en.jpg?imgmax=144"><img border="0" class="blogimg" src="http://lh6.google.com/image/wanglei1123/RbhFbSUMdZI/AAAAAAAAACs/xB5rdh0oU00/vim-en.jpg?imgmax=144"></a></div>
<p><a target="_blank" href="http://lh6.google.com/image/wanglei1123/RbhFbSUMdYI/AAAAAAAAACk/zUsYqA6s2KY/vim-zh.jpg?imgmax=144"><br />
</a></div>
<p></span></font></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.gnome.org/raywang/2007/01/25/vim-%e9%94%ae%e7%9b%98%e5%9b%be/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  blogs.gnome.org/raywang/category/free-software/vim/feed/ ) in 1.32288 seconds, on Feb 12th, 2012 at 12:04 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 12th, 2012 at 1:04 am UTC -->
