﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-I Know you Know</title><link>http://www.cppblog.com/DrMagic/</link><description /><language>zh-cn</language><lastBuildDate>Thu, 23 Apr 2026 10:14:15 GMT</lastBuildDate><pubDate>Thu, 23 Apr 2026 10:14:15 GMT</pubDate><ttl>60</ttl><item><title>Vim 参考指南</title><link>http://www.cppblog.com/DrMagic/archive/2007/11/23/37195.html</link><dc:creator>Dr.Magic</dc:creator><author>Dr.Magic</author><pubDate>Fri, 23 Nov 2007 03:37:00 GMT</pubDate><guid>http://www.cppblog.com/DrMagic/archive/2007/11/23/37195.html</guid><wfw:comment>http://www.cppblog.com/DrMagic/comments/37195.html</wfw:comment><comments>http://www.cppblog.com/DrMagic/archive/2007/11/23/37195.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DrMagic/comments/commentRss/37195.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DrMagic/services/trackbacks/37195.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: *quickref.txt*&nbsp;&nbsp; &nbsp;For Vim version 7.1.&nbsp; 最近更新: 2007年5月&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; VIM REFERENCE MANUAL&nbsp;&nbsp;&nbsp; by Bram Moolenaar&nbsp;&nbsp; &nbsp;&nbsp;&...&nbsp;&nbsp;<a href='http://www.cppblog.com/DrMagic/archive/2007/11/23/37195.html'>阅读全文</a><img src ="http://www.cppblog.com/DrMagic/aggbug/37195.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DrMagic/" target="_blank">Dr.Magic</a> 2007-11-23 11:37 <a href="http://www.cppblog.com/DrMagic/archive/2007/11/23/37195.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Emacs 快速指南</title><link>http://www.cppblog.com/DrMagic/archive/2007/11/22/37149.html</link><dc:creator>Dr.Magic</dc:creator><author>Dr.Magic</author><pubDate>Thu, 22 Nov 2007 09:53:00 GMT</pubDate><guid>http://www.cppblog.com/DrMagic/archive/2007/11/22/37149.html</guid><wfw:comment>http://www.cppblog.com/DrMagic/comments/37149.html</wfw:comment><comments>http://www.cppblog.com/DrMagic/archive/2007/11/22/37149.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DrMagic/comments/commentRss/37149.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DrMagic/services/trackbacks/37149.html</trackback:ping><description><![CDATA[Emacs 快速指南.（查看版权声明请至本文末尾）<br><br>【注意：位于【】之间的内容是译注，比如本行，下同。】<br><br>Emacs 键盘命令通常包含 CONTROL 键（有时候以 CTRL 或 CTL 来标示）和<br>META 键（有时候用 EDIT 或 ALT 来标示）。为了避免每次都要写出全名，我们<br>约定使用下述缩写：<br><br>&nbsp;C-&lt;chr&gt;&nbsp; 表示当输入字符 &lt;chr&gt; 时按住 CONTROL 键。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 因此 C-f 就表示：按住 CONTROL 键再输入 f。<br><br>&nbsp;M-&lt;chr&gt;&nbsp; 表示当输入字符 &lt;chr&gt; 时按住 META（或 EDIT 或 ALT）键。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果你的键盘上没有 META 、EDIT 或 ALT 键，用下述方法也等效：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 先按一下 ESC 键然后放开，再输入 &lt;chr&gt;。我们用 &lt;ESC&gt; 来表示<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ESC 键。<br><br>重要提示：要退出 Emacs，请用 C-x C-c（两个连续的组合键）。下文中左边顶<br>行的&#8220;&gt;&gt;&#8221;字样用来提示你尝试键盘命令。比如：<br><br><br><br><br><br><br><br>&gt;&gt; 现在输入 C-v （查看下一屏文字）移动到下一屏。<br>&nbsp;&nbsp; （别紧张，在输入字符 v 的同时注意要按住 CONTROL 键）<br>&nbsp;&nbsp; 从现在开始，每读完当前一屏你都需要这样做一次。<br><br>值得注意的是，当你从上一屏滚到下一屏时，中间会有两行的重复；这样做是为<br>了维持滚屏的连续性，方便你顺畅、连续地阅读。<br><br>用编辑器，开门第一件事就是学会在文字中移动。你已经知道了 C-v 可以向下移<br>动一屏，要往上移，请用 M-v （也就是按住 META 键，然后输入v，如果你没有<br>META、EDIT 或 ALT 键那么就先按 &lt;ESC&gt; 再按 v）。<br><br>&gt;&gt;&nbsp; 试试 M-v，然后再试试 C-v，来回遛几次。<br><br><br>* 小结（SUMMARY）<br>-----------------<br><br>以下命令在翻页浏览时相当有用：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-v&nbsp;&nbsp;&nbsp;&nbsp; 向前移动一屏<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M-v&nbsp;&nbsp;&nbsp;&nbsp; 向后移动一屏<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-l&nbsp;&nbsp;&nbsp;&nbsp; 重绘屏幕，并将光标所在行置于屏幕的中央<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; （注意是 CONTROL-L，不是 CONTROL-1）<br><br>&gt;&gt; 找到光标，留意其附近的文字，然后输入 C-l。<br>&nbsp;&nbsp; 找找光标在哪里，你会发现其附近的文字并没有变化。<br><br>如果你的键盘上有 PageUp 和 PageDn，也可以用这两个键来滚屏。不过使用<br>C-v 和 M-v 的效率要更高一些。<br><br><br>* 基本的光标控制（BASIC CURSOR CONTROL）<br>----------------------------------------<br><br>整屏的移动很有用，但是如何在文字中精确定位呢？<br><br>有几种方式可以选择。用方向键当然可以，不过更有效率的方法是保持双手位于<br>主键盘区，然后使用 C-p 、 C-b 、 C-f 和 C-n 这四个命令。它们的功能和方<br>向键是一样的，如下图所示：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 上一行 C-p<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 向左移 C-b .... 目前光标位置 .... 向右移 C-f<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 下一行 C-n<br>n<br>&gt;&gt; 用 C-n 或 C-p 将光标移到上图的中央。<br>&nbsp;&nbsp; 按 C-l，整幅图会被显示在屏幕的中央。<br><br>&#8220;P N B F&#8221;四个字母分别代表了四个词，用这四个词记忆这些组合键会更容易：<br>P 代表 previous（上一行），N 代表 next（下一行），B 代表 backward（回<br>退），而 F 则代表 forward（前进）。这些组合键今后将与你形影不离。<br><br>&gt;&gt; 按几次 C-n 把光标往下挪到这里。<br><br>&gt;&gt; 用 C-f 把光标移动到这一行，然后再用 C-p 往上挪。<br>&nbsp;&nbsp; 注意观察当光标在一行的中央时 C-p 命令的行为。<br><br>每行文字都以一个&#8220;换行符&#8221;结束，&#8220;换行符&#8221;把行与行区分开来。文件的最后<br>一行也应该也有一个换行符（不过 Emacs 并不强制要求这一点）。<br><br>&gt;&gt; 在一行的行头输入 C-b。<br>&nbsp;&nbsp; 光标应该会移动到前一行的行尾，因为光标在回退过程中越过了换行符。<br><br>同样 C-f 也可以像 C-b 一样越过换行符。<br><br>&gt;&gt; 连按几次 C-b，感受一下光标的移动。<br>&nbsp;&nbsp; 然后按几次 C-f 回到本行的行尾。<br>&nbsp;&nbsp; 再按一次 C-f，光标会移动到下一行。<br><br>当你移动光标穿越屏幕的上下边界时，在边界外的文字会移动到屏幕内，这称为<br>&#8220;滚动&#8221;（scrolling）。滚动使得光标可以被移动到文字中的任何位置，并且还<br>不会让光标跑到屏幕外边去。<br><br>&gt;&gt; 用 C-n 将光标下移，一直越过屏幕边界，同时观察发生了什么变化。<br><br>如果你嫌一个字符一个字符地挪光标太慢，你还可以一个词一个词地跳。M-f<br>(META-f) 可以将光标往前移动一个词，而 M-b 则是往后移。【这里的&#8220;词&#8221;指<br>英文单词，对中文来说，则是指移动到下一个标点符号。】<br><br>&gt;&gt; 试试 M-f 和 M-b。<br><br>如果光标停在一个词的中间，M-f 会移动到这个词的末尾。如果光标处于词与词<br>之间的空白处，M-f 会移动到下一个词的末尾。M-b 的功能类似，只是方向相反。<br><br>&gt;&gt; 按几次 M-f 和 M-b，中间夹杂一些 C-f 和 C-b。<br>&nbsp;&nbsp; 你可以观察到 M-f 和 M-b 在不同位置上所表现出来的不同行为。<br><br>请注意 C-f 、C-b 和 M-f 、M-b 两对之间的类比关系。通常的惯例是：META 系<br>列组合键用来操作&#8220;由语言定义的单位（比如词、句子、段落）&#8221;，而 CONTROL<br>系列组合键用来操作&#8220;与语言无关的基本单位（比如字符、行等等）&#8221;。<br><br>类似的惯例在&#8220;行&#8221;与&#8220;句子&#8221;之间也同样适用：C-a 和 C-e 可以将光标移动到<br>&#8220;一行&#8221;的头部和尾部；而 M-a 和 M-e 则将光标移动到&#8220;一句&#8221;的头部和尾部。<br><br>&gt;&gt; 按两次 C-a，再按两次 C-e。<br>&nbsp;&nbsp; 按两次 M-a，再按两次 M-e。<br><br>想一想为什么重复的 C-a 命令会没有作用，而重复的 M-a 命令则会让光标不断<br>地回退到上一个句子。虽然这个类比规律并不严格，但是很自然。<br><br>光标停留的位置也可以称作&#8220;点位&#8221;（point）。或者干脆说，光标指示出了屏幕<br>上&#8220;点位&#8221;在文本中的位置。<br><br>这里对简单的光标移动命令做一个总结，其中也包括了整词和整句的移动：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-f&nbsp;&nbsp;&nbsp;&nbsp; 向右移动一个字符<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-b&nbsp;&nbsp;&nbsp;&nbsp; 向左移动一个字符<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M-f&nbsp;&nbsp;&nbsp;&nbsp; 向右移动一个词【对中文是移动到下一个标点符号】<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M-b&nbsp;&nbsp;&nbsp;&nbsp; 向左移动一个词【对中文是移动到上一个标点符号】<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-n&nbsp;&nbsp;&nbsp;&nbsp; 移动到下一行<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-p&nbsp;&nbsp;&nbsp;&nbsp; 移动到上一行<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-a&nbsp;&nbsp;&nbsp;&nbsp; 移动到行首<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-e&nbsp;&nbsp;&nbsp;&nbsp; 移动到行尾<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M-a&nbsp;&nbsp;&nbsp;&nbsp; 移动到句首<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M-e&nbsp;&nbsp;&nbsp;&nbsp; 移动到句尾<br><br>&gt;&gt; 把上面所有的命令都练习几次，这些可都是最常用的命令。<br><br>这里还要介绍两个重要的光标移动命令：M-&lt; （META 小于号）可以将光标移动到<br>所有文字的最开头；M-&gt; （META 大于号）可以将光标移动到所有文字的最末尾。<br><br>注意，在大部分键盘上，小于号（&lt;）需要用上档键（Shift）来输入，所以在这<br>些键盘上你应该用 Shift 键来输入 M-&lt;，如果不按 Shift 键，你输入的会是<br>M-comma（META 逗号）。<br><br>&gt;&gt; 试一试 M-&lt; ，移到本快速指南的最开始。<br>&nbsp;&nbsp; 然后再按几次 C-v 回到这里。<br><br>&gt;&gt; 试一试 M-&gt; ，移到本快速指南的最末尾。<br>&nbsp;&nbsp; 然后再按几次 M-v 回到这里。<br><br>如果你的键盘上有方向键的话，也可以用它们来移动光标。不过我们有三个理由<br>推荐你学习 C-b 、C-f 、C-n 、和 C-p：（1）它们在任何键盘上都能用。（2）<br>当你熟练使用 Emacs 之后，你会发现用这些组合键比用方向键要快得多，因为你<br>的手不需要离开打字区。（3）一旦你习惯了使用这些组合键，你也可以很容易地<br>适应其它更高级的光标移动命令。<br><br>大部分的 Emacs 命令接受数字参数，并且对于多数命令而言，这些数字参数的作<br>用是指定命令的重复次数。为一个命令指定数字参数（也就是重复次数）的方法<br>是：先输入 C-u，然后输入数字作为参数，最后再输入命令。如果你有META （或<br>EDIT 或 ALT）键，那么还有另一种办法：按住 META 键不放，然后输入数字。不<br>过我们还是建议你用 C-u，因为它在任何终端机上都能用。这种数字参数也称为<br>&#8220;前缀参数&#8221;，意思是说这个参数是先于使用它的命令而输入的。<br><br>举例来说， C-u 8 C-f 会向前移动 8 个字符。<br><br>&gt;&gt; 为 C-n 或者 C-p 指定一个数字参数，这样你可以只用一个命令就把光标移动<br>&nbsp;&nbsp; 到本行的附近。<br><br>虽然大部分命令把数字参数解释为其重复次数，但是也有些命令例外，它们将数<br>字参数另做它用。比如有些命令（我们目前还没学到）仅仅将前缀参数作为一个<br>标志――只要给出有一个前缀参数，不管其值为何，它都会改变命令的功能。<br><br>而 C-v 和 M-v 则属于另一种类型的例外。当给定一个参数时，它们将滚动你指<br>定的&#8220;行数&#8221;，而不是&#8220;屏数&#8221;。举例来说，C-u 8 C-v 将屏幕向下滚动 8 行，<br>而不是 8 屏。<br><br><br>&gt;&gt; 现在试试看，输入 C-u 8 C-v。<br><br>这个命令应该已经将文字向上滚动了 8 行。如果你想将它再次地向下滚动，你可<br>以给定一个参数然后执行 M-v。<br><br><br>如果你正在使用一个窗口系统，比如 X11 或者微软的 Windows，那么在 Emacs<br>窗口的边缘应该有一个长方形的区域叫&#8220;滚动条&#8221;，你可以用鼠标操纵滚动条来<br>滚动文字。<br><br>&gt;&gt; 试着在&#8220;滚动条内的反白区域&#8221;上按一下鼠标中键。<br>&nbsp;&nbsp; 文字应该会滚动到鼠标所指示的位置。<br><br>&gt;&gt; 当按住中键时，试着将鼠标上下移动。<br>&nbsp;&nbsp; 你会看到文字随着鼠标的移动而上下滚动。<br>&nbsp;&nbsp; 【Windows 版本符合 Windows 程序的传统操作习惯，上述操作不适用。】<br><br><br>* 在 EMACS 失去响应的时候（WHEN EMACS IS HUNG）<br>-----------------------------------------------<br><br>如果 Emacs 对你的命令失去响应，你可以用 C-g 来安全地终止这条命令。C-g<br>也可以终止一条执行过久的命令。<br><br>C-g 还可以取消数字参数和只输入到一半的命令。<br><br>&gt;&gt; 输入 C-u 100 设定一个值为 100 的数字参数，然后按 C-g。<br>&nbsp;&nbsp; 现在再按 C-f，光标应该只会移动一个字符，因为你已经用 C-g 取消了参数。<br><br>如果你不小心按了一下 &lt;ESC&gt;，你也可以用 C-g 来取消它。<br>【这个说法似乎有问题，因为按照这个按键顺序输入的应该是 C-M-g。<br>&nbsp; 取消 &lt;ESC&gt; 的正确做法是再连按两次 &lt;ESC&gt;。】<br><br><br>* 被禁用的命令（DISABLED COMMANDS）<br>-----------------------------------<br><br>有一些 Emacs 命令被&#8220;禁用&#8221;了，以避免初学者在不了解其确切功能的情况下误<br>用而造成麻烦。<br><br>如果你用到了一个被禁用的命令，Emacs 会显示一个提示消息，告诉你这个命令<br>到底是干什么的，询问你是否要继续，并在得到你的肯定之后再执行这命令。<br><br>如果你真的想用这条命令，在 Emacs 询问你的时候应该按空格。一般来说，如果<br>你不想用，就按&#8220;n&#8221;。<br><br>&gt;&gt; 试试 C-x C-l （这是一个被禁用的命令）<br>&nbsp;&nbsp; 然后用 n 来回答询问。<br><br><br>* 窗格（WINDOWS）<br>-----------------<br><br>Emacs 可以有多个窗格，每个窗格显示不同的文字。后面会介绍怎么对付多个窗<br>格，现在我们先学会如何关掉多余的窗格。其实也很简单：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x 1&nbsp;&nbsp; 只保留一个窗格（也就是关掉其它所有窗格）。<br><br>也就是先按 CONTROL-x 然后再按 1。C-x 1 会保留光标所在的窗格，并将其扩大<br>到整个屏幕，同时关掉所有其它的窗格。<br><br>&gt;&gt; 把光标移到本行然后输入 C-u 0 C-l。<br><br>&gt;&gt; 输入 CONTROL-h k CONTROL-f。观察当一个新窗格出现时当前窗格（用来显示<br>&nbsp;&nbsp; CONTROL-f 命令的文档）是如何缩小的。<br><br>&gt;&gt; 输入 C-x 1 关掉文档窗格。<br><br>这个命令跟先前学过的命令不太一样，因为它包含了两个字符，以 CONTROL-x 开<br>始。有一系列命令都是以 CONTROL-x 开始的，这些命令许多都跟&#8220;窗格、文件、<br>缓冲区【缓冲区（buffer）会在后文详细介绍】&#8221;等等诸如此类的东西有关，其<br>中有些命令可能包含了 2 个、3 个或者 4 个字符。<br><br><br>* 插入与删除（INSERTING AND DELETING）<br>--------------------------------------<br><br>插入文字很简单，直接敲键盘就可以了。你能看到的字符，比如 A、7、* 等等，<br>都被 Emacs 视为文字并且可以直接插入。敲 &lt;Return&gt;（回车键）会插入一个换<br>&nbsp;v行符。<br><br>你可以用 &lt;Delback&gt; 来删除最后输入的一个字符，这个跟你在 Emacs 之外的用<br>法应该一样。一般来说 &lt;Delback&gt; 就是位于 &lt;Return&gt; 键上方某处的一个大块头<br>的键，通常被标示为&#8220;Delete&#8221;、&#8220;Del&#8221;或者&#8220;Backspace&#8221;。<br><br>如果你找到了&#8220;Backspace&#8221;键，那么它应该就是 &lt;Delback&gt;；这时哪怕你又在别<br>的地方找到了一个&#8220;Del&#8221;键，那么它也应该不是 &lt;Delback&gt;。<br><br>一种更通用的说法是，&lt;Delback&gt; 将删除位于光标前的一个字符。<br><br>&gt;&gt; 现在就来试试――敲点字，然后按几下 &lt;Delback&gt; 删除它们。<br>&nbsp;&nbsp; 不用担心文件被修改，你做什么都没关系，这里就是专给你练习用的。<br><br>如果一行文字很长、超出了窗格的宽度，显示不下的部分会在紧邻的下一行继续<br>显示。这时会有一个反斜线（在控制台下是反斜线，如果你用图形窗口系统，则<br>应该是一个小小的转弯箭头）显示在右边沿，表明这是某一行的接续显示。<br><br>&gt;&gt; 输入文字，一直到屏幕的右边界，然后继续，你会看到一个接续行出现。<br><br>&gt;&gt; 用 &lt;Delback&gt; 删掉一些文字，直到此行长度小于窗格宽度，接续行就消失了。<br><br>换行符跟其它字符一样可以被删除。两行中间的换行符被删除后，这两行将会合<br>并成一行。如果合并后的这一行太长，超出了窗格宽度，它就会以一个接续行来<br>显示。<br><br>&gt;&gt; 移动光标到某行的开头并输入 &lt;Delback&gt;。<br>&nbsp;&nbsp; 这时该行将与其前一行一起被合并为一行。<br><br>&gt;&gt; 输入 &lt;Return&gt; 重新插入你刚才删除的换行符。<br><br>前面讲过，大部分的 Emacs 命令都可以指定重复次数，这其中也包括输入字符的<br>命令。重复执行输入字符的命令实际上就是输入多个相同的字符。<br><br>&gt;&gt;&nbsp; 试试 C-u 8 *，这将会插入 ********。<br><br>好，现在你应该已经掌握了最基本的的文本插入和修改功能，其实删除还可以<br>&#8220;以词为单位&#8221;进行，下面是一个关于&#8220;删除&#8221;操作的小结：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Delback&gt;&nbsp;&nbsp;&nbsp; 删除光标前的一个字符<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-d&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 删除光标后的一个字符<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M-&lt;Delback&gt;&nbsp; 移除光标前的一个词<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M-d&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 移除光标后的一个词<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-k&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 移除从光标到&#8220;行尾&#8221;间的字符<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M-k&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 移除从光标到&#8220;句尾&#8221;间的字符<br><br>【可能你已经注意到了&#8220;删除（delete）&#8221;和&#8220;移除（kill）&#8221;的用词区别，后<br>文会有详细说明。】<br><br>注意&#8220;&lt;Delback&gt; 和 C-d&#8221;还有&#8220;M-&lt;Delback&gt; 和 M-d&#8221;是根据前述惯例从 C-f<br>和 M-f 衍生出来的（其实&lt;Delback&gt;不是控制字符，我们先忽略这一点）。C-k<br>和 M-k 的关系在某种程度上与 C-e 和 M-e 一样――如果把&#8220;一行&#8221;和&#8220;一句&#8221;<br>作一个类比的话。<br><br>你也可以用一种通用的办法来移除缓冲区里的任何一部分：首先把光标移动到你<br>想要移除的区域的一端，然后按 C-@ 或 C-SPC（任一即可，SPC指空格）【注意，<br>C-SPC 往往被中文用户设定成输入法热键，如果这样，C-SPC 就被系统拦截而无<br>法传递给 Emacs 了，因此这里还是推荐使用C-@。】，然后将光标移动到另一端，<br>再按 C-w 就可以把位于这两点之间的所有文字移除了。<br><br>&gt;&gt; 移动光标到上一段开头的&#8220;你&#8221;字。<br>&gt;&gt; 输入 C-@ 。Emacs 应该会在屏幕的下方显示一个&#8220;Mark set&#8221;的消息。<br>&gt;&gt; 移动光标到第二行中的&#8220;端&#8221;字。<br>&gt;&gt; 输入 C-w，从&#8220;你&#8221;开始到&#8220;端&#8221;之前的文字被全部移除。<br><br>注意,&#8220;移除（kill）&#8221;和&#8220;删除（delete）&#8221;的不同在于被移除的东西可以找回<br>来，而被删除的就不行了。【实际上，移除掉的东西虽然看起来&#8220;消失&#8221;了，但<br>实际上被 Emacs 记录了下来，因此还可以找回来；而删除掉的东西虽然也可能还<br>在内存里，但是已经被 Emacs&#8220;抛弃&#8221;了，所以就找不回来了。】重新插入被移<br>除的文字称为&#8220;召回（yank）&#8221;。一般而言，那些可能消除很多文字的命令会把<br>消除掉的文字记录下来（它们被设定成了&#8220;可召回&#8221;），而那些只消除一个字符<br>或者只消除空白的命令就不会记录被消除的内容（自然你也就无法召回了）。<br><br>&gt;&gt; 移动光标到一非空白行的行头，然后输入 C-k 移除那一行上的文字。<br><br>&gt;&gt; 再次 C-k，你可以看到它移除了跟在那一行后面的换行符。<br><br>注意，单独的 C-k 会把一行的内容移除，而第二个 C-k 则会移除换行符，并使<br>其后所有的行都向上移动。C-k 处理数字参数的方式很特别，它会把参数指定的<br>那么多行连同其后的换行符一起移除，而不仅仅是重复 C-k 而已。比如 C-u 2<br>C-k 会把两行以及它们的换行符移除；而如果只是输入 C-k 两次显然不是这个结<br>果。<br><br>将被移除的文字恢复的动作称为&#8220;召回（yanking）&#8221;。（就好像把别人从你身边<br>移走的东西又猛力地拉回来。）你可以在你删除文字的地方召回，也可以在别的<br>地方召回，还可以多次召回同样的文字以得到它的多个拷贝。<br><br>召回的命令是 C-y。它会在光标所在处插入你最后移除的文字。<br><br>&gt;&gt; 试试看，输入 C-y 将文字召回。<br><br>如果你一次连按了好几下 C-k，那么所有被移除的行会被存储在一起，只要一个<br>C-y 就可以把它们都召回。<br><br>&gt;&gt; 在这里试试，连续按几次 C-k。<br><br>现在再来恢复刚刚被我们移除的文字：<br><br>&gt;&gt; 按 C-y。然后把光标往下移动几行，再按一次 C-y。<br>&nbsp;&nbsp; 现在你应该知道怎么复制文字了。<br><br>C-y 可以召回最近一次移除的内容，那如何召回前几次移除的内容呢？它们当然<br>没有丢，你可以用 M-y 来召回它们。在用 C-y 召回最近移除的文字之后，紧接<br>着再按 M-y 就可以召回再前一次被移除的内容，再按一次 M-y 又可以召回再上<br>一次的&#8230;&#8230;连续使用 M-y 直到找到你想要召回的东西，然后什么也不用做，继续<br>编辑就行了。<br><br>如果连续按 M-y 很多次，你可能会回到起始点，也就是最近移除的文字。<br>【看得出这实际上是一个环。】<br><br>&gt;&gt; 移除一行，移动一下光标，然后再移除另外一行。<br>&nbsp;&nbsp; 按 C-y 将第二次移除的那行召回来。<br>&nbsp;&nbsp; 紧接着再按 M-y，它将会被第一次移除的那行取代。<br>&nbsp;&nbsp; 试着再按几下 M-y 看看会发生什么。<br>&nbsp;&nbsp; 再继续，直到第二行被召回来，然后再做个几次。<br>&nbsp;&nbsp; 如果感兴趣，你可以试着给 M-y 指定一个正的或负的参数。<br><br><br>* 撤销（UNDO）<br>--------------<br><br>如果你修改了一段文字，又觉得改得不好，可以用 undo 命令进行撤销：<br>C-x u。<br><br>通常 C-x u 会消除一个命令所造成的所有改变；如果你在一行中连续多次地使用<br>C-x u，你会把以前的命令也依次撤销。<br><br>但是有两个例外：<br>1） 没有改变文字的命令不算（包括光标移动命令和滚动命令）<br>2） 从键盘输入的字符以组为单位――每组 20 个字符――来进行处理。<br>&nbsp;&nbsp;&nbsp; （这是为了减少你在撤销&#8220;插入文字&#8221;动作时需要输入 C-x u 的次数）<br><br>&gt;&gt; 用 C-k 将这一行移除，然后输入 C-x u ，它会再次出现。<br><br>C-_ 也是撤销命令；它的作用跟 C-x u 一样，但是它比较容易多次输入。C-_ 的<br>缺点是在某些键盘上可能不太容易按，这也正是我们同时提供 C-x u 的原因。在<br>某些终端上，你可以按住 CONTROL 再按&#8220;/&#8221;来输入 C-_。<br><br>数字参数对于 C-_ 和 C-x u 的意义是执行撤销的重复次数。<br><br><br>* 文件（FILE）<br>--------------<br><br>想保存工作成果就要记得存盘，否则一旦退出 Emacs 你编辑的文字就会丢失。要<br>存盘，就要在编辑前&#8220;寻找&#8221;到一个存盘文件。（这个过程通常也被称为&#8220;访问&#8221;<br>文件。）<br><br>寻找到一个文件意味着你可以在 Emacs 里查看这个文件的内容。从许多角度看，<br>这就等于你在直接编辑这个文件，只是你所做的修改只有在&#8220;存盘&#8221;的时候才会<br>被写入文件。也正因为如此，你可以丢弃一个写到一半的文件而不必把这个残缺<br>文件也保存到计算机上。在存盘的时候，Emacs 会把存盘前的文件重命名保存，<br>以防你改完之后又想反悔。<br><br>在屏幕的下方，你应该能够看到头尾都是短线&#8220;-&#8221;的一行，行首通常是一些诸如<br>&#8220;--:-- TUTORIAL.cn&#8221;的文字，这些文字代表了你当前正在访问的文件。比如你<br>现在正在访问的文件叫&#8220;TUTORIAL.cn&#8221;，它只是一个给你临时使用的拷贝。每当<br>Emacs 寻找到一个文件，文件名就会出现在这个位置。<br><br>寻找文件的命令有一个特点，那就是你必须给出文件名。我们称这个命令&#8220;从终<br>端读入了一个参数&#8221;（在这里，这个参数显然就是文件名）。在你输入这条命令<br>之后：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x C-f&nbsp;&nbsp; 寻找一个文件<br><br>Emacs 会提示你输入文件名。你输入的文件名会出现在屏幕最底端的一行，这一<br>行被称为小缓冲（minibuffer），在小缓冲里你可以使用通常的 Emacs 编辑命令<br>来编辑文件名。<br><br>在小缓冲里输入文件名（其实输入其它东西也一样）时可以用 C-g 取消。<br><br>&gt;&gt; 输入 C-x C-f，然后输入 C-g<br>&nbsp;&nbsp; 这会关掉小缓冲，同时也会取消使用小缓冲的 C-x C-f 命令。<br>&nbsp;&nbsp; 当然了，你也没有找任何文件。<br><br>用 &lt;Return&gt; 结束文件名的输入。这之后 C-x C-f 命令开始工作并找到你指定的<br>文件。小缓冲在 C-x C-f 命令结束之后也会消失。<br><br>眨眼间文件就被显示在屏幕上，你可以开始编辑了。存盘用这条命令：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x C-s&nbsp;&nbsp; 储存这个文件<br><br>这条命令把 Emacs 中的文字存储到文件中。第一次存盘的时候 Emacs 会将原文<br>件重命名以备份。重命名的规则通常是在原文件名之后添加一个&#8220;~&#8221;字符。<br>【对许多人来说，这是一个烦人的特性，关掉文件备份可以用如下命令：<br>&nbsp; M-x customize-variable &lt;Return&gt; make-backup-files &lt;Return&gt;】<br><br>存盘结束后，Emacs 会显示写入文件的文件名。你最好养成经常存盘的习惯，这<br>可以减少系统崩溃和死机给你带来的损失。<br><br>&gt;&gt; 输入 C-x C-s 把本快速指南存下来。<br>&nbsp;&nbsp; 你会在屏幕的下方看到一条消息：&#8220;Wrote ...TUTORIAL.cn&#8221;。<br><br>注意：在某些终端下，输入 C-x C-s 会冻结屏幕【屏幕没有任何输出】，使你看<br>不到 Emacs 的任何变化。其原因是操作系统的&#8220;流量控制&#8221;功能拦截了 C-s 并<br>冻结了屏幕。用 C-q 可以解除屏幕冻结。要解决这个问题，请参考 Emacs 手册<br>里的&#8220;Spontaneous Entry to Incremental Search&#8221;一节【Emacs 手册可能还没<br>有中文翻译】，那里提供了一些有用的建议。<br><br>你不但可以寻找一个已有的文件来查看或编辑，还可以寻找一个不存在的文件。<br>实际上这正是 Emacs 创建新文件的方法：找到不存在的新文件。只有在存盘的时<br>候，Emacs 才会真正创建这个文件。而在这之后的一切就跟编辑一个已有文件没<br>有区别了。<br><br><br>* 缓冲区（BUFFER）<br>------------------<br><br>你可以用 C-x C-f 找到并打开第二个文件，但第一个文件仍然在 Emacs 中。要<br>切回第一个文件，一种办法是再用一次 C-x C-f。这样，你就可以在 Emacs 中同<br>时打开多个文件。<br><br>&gt;&gt; 用 C-x C-f foo &lt;Return&gt; 的方式建立一个名为&#8220;foo&#8221;的文件。<br>&nbsp;&nbsp; 输入一些文字，再用 C-x C-s 保存文件&#8220;foo&#8221;。<br>&nbsp;&nbsp; 最后，输入 C-x C-f TUTORIAL.cn &lt;Return&gt; 回到这里。<br><br>Emacs 把每个编辑中的文件都放在一个称为&#8220;缓冲区（buffer）&#8221;的地方。每寻<br>找到一个文件，Emacs 就在其内部开辟一个缓冲区。用下面的命令可以列出当前<br>所有的缓冲区：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x C-b&nbsp;&nbsp; 列出缓冲区<br><br>&gt;&gt; 现在就试一下 C-x C-b<br><br>观察一下缓冲区是如何被命名的，它很可能跟与其对应的文件同名。实际上，一<br>个 Emacs 窗格里的任何文字都是某个缓冲区的一部分。<br><br>&gt;&gt; 输入 C-x 1 离开缓冲区列表<br><br>不管存在多少缓冲区，任何时候都只能有一个&#8220;当前&#8221;缓冲区，也就是你正在编<br>辑的这个。如果你想编辑其它的缓冲区，就必须&#8220;切换&#8221;过去。上面讲过，用<br>C-x C-f 是一种办法。不过还有一个更简单的办法，那就是用 C-x b。用这条命<br>令，你必须输入缓冲区的名称。<br><br>&gt;&gt; 输入 C-x b foo &lt;Return&gt; 以回到文件&#8220;foo&#8221;的缓冲区。<br>&nbsp;&nbsp; 然后输入 C-x b TUTORIAL.cn &lt;Return&gt; 回到这里。<br><br>大多数情况下，缓冲区与跟其对应的文件是同名的（不包括目录名），不过这也<br>不是绝对的。用 C-x C-b 得到的缓冲区列表总是显示缓冲区名。<br><br>你在 Emacs 窗格里看到的&#8220;任何&#8221;文字都一定属于某个缓冲区。然而，缓冲区未<br>必有对应文件：比如显示缓冲区列表的缓冲区就是这样。再比如&#8220;*Messages*&#8221;<br>缓冲区也没有对应文件，这个缓冲区里存放的都是在 Emacs 底部出现的消息。<br><br>&gt;&gt; 输入 C-x b *Messages* &lt;Return&gt; 瞅瞅消息缓冲区里都有什么东西。<br>&nbsp;&nbsp; 然后再输入 C-x b TUTORIAL.cn &lt;Return&gt; 回到这里。<br><br>如果你对某个文件做了些修改，然后切换到另一个文件，这个动作并不会帮你把<br>前一个文件存盘。对第一个文件的修改仍然仅存在于 Emacs 中，也就是在它对应<br>的缓冲区里。并且，对第二个文件的修改也不会影响到第一个文件。这很有用，<br>但是也挺麻烦：因为如果你想要存储第一个文件，还需要先 C-x C-f 切换回去再<br>用 C-x C-s 存盘。你需要一个更简便的方法，而 Emacs 已经为你准备好了：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x s&nbsp;&nbsp; 保存多个缓冲区<br><br>C-x s 会找出所有已被修改但尚未存盘的缓冲区，然后向你逐个询问：是否需要<br>存盘？<br><br>&gt;&gt; 插入一行文字，然后输入 C-x s。<br>&nbsp;&nbsp; 它应该会问你，是否要储存名为 TUTORIAL.cn 的缓冲区？<br>&nbsp;&nbsp; 按&#8220;y&#8221;告诉它你想存盘。<br><br><br>* 命令集扩展（EXTENDING THE COMMAND SET）<br>-----------------------------------------<br><br>Emacs 的命令就像天上的星星，数也数不清。把它们都对应到 CONTROL 和 META<br>组合键上显然是不可能的。Emacs 用扩展（eXtend）命令来解决这个问题，扩展<br>命令有两种风格：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x&nbsp;&nbsp;&nbsp;&nbsp; 字符扩展。&nbsp; C-x 之后输入另一个字符或者组合键。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; M-x&nbsp;&nbsp;&nbsp;&nbsp; 命令名扩展。M-x 之后输入一个命令名。<br><br>很多扩展命令都相当有用，虽然与你已经学过的命令比起来，他们可能不那么常<br>用。我们早已经见过一些扩展命令了，比如用 C-x C-f 寻找文件和用 C-x C-s<br>保存文件；退出 Emacs 用的 C-x C-c 也是扩展命令。（不用担心退出 Emacs 会<br>给你带来什么损失，Emacs 会在退出之前提醒你存盘的）<br><br>在控制台下，C-z 可以暂时离开 Emacs――当然，你还可以再回来。<br><br>在允许 C-z 的系统中，C-z 会把 Emacs&#8220;挂起&#8221;，也就是说，它会回到 shell<br>但不退出 Emacs。在常用的 shell 中，通常可以用&#8220;fg&#8221;或者&#8220;%emacs&#8221;命令再<br>次回到 Emacs 中。<br><br>在没有提供挂起功能的系统中，C-z 会在 Emacs 之下创建一个子 shell 来让你<br>运行其它程序，并且再次&#8220;回到&#8221;Emacs 中――虽然我们并没有真正离开过。这<br>种情况下，通常用 shell 命令&#8220;exit&#8221;从子 shell 回到 Emacs。<br><br>你最好在打算退出登陆的时候再用 C-x C-c。在 Emacs 被诸如邮件处理程序之类<br>的外部程序调用之后，也可以用 C-x C-c 退出。不过一般来讲，如果你不想退出<br>登录，最好还是把 Emacs 挂起而不是退出。<br><br>C-x 的扩展命令有很多，下面列出的是你已经学过的：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x C-f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 寻找文件。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x C-s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 保存文件。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x C-b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 列出缓冲区。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x C-c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 离开 Emacs。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 关掉其它所有窗格，只保留一个。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-x u&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 撤销。<br><br>用命令名扩展的命令通常并不常用，或只用在部分模式下。比如 replace-string<br>（字符串替换）这个命令，它会在全文范围内把一个字符串替换成另一个。在输<br>入 M-x 之后，Emacs 会在屏幕底端向你询问并等待你输入命令名。如果你想输入<br>&#8220;replace-string&#8221;，其实只需要敲&#8220;repl s&lt;TAB&gt;&#8221;就行了，Emacs 会帮你自动<br>补齐。输入完之后按 &lt;Return&gt; 。<br><br>字符串替换命令需要两个参数――被替换的字符串和用来替换它的字符串。每个<br>参数的输入都以换行符来结束。<br><br>&gt;&gt; 将光标移到本行下面第二行的空白处，然后输入<br>&nbsp;&nbsp; M-x repl s&lt;Return&gt;changed&lt;Return&gt;altered&lt;Return&gt;。<br><br>&nbsp;&nbsp; 【以下保留一行原文，以应练习之需：】<br>&nbsp;&nbsp; Notice how this line has changed: you've replaced... <br><br>请注意这一行的变化：在光标之后的范围内，你已经将&#8220;changed&#8221;这个词――不<br>论它在哪里出现――全部用&#8220;altered&#8221;替换掉了。<br><br><br>* 自动保存（AUTO SAVE）<br>-----------------------<br><br>如果你已经修改了一个文件，但是还没来得及存盘你的计算机就罢工了，那么你<br>所做的修改就很可能会丢失。为了避免这样的不幸发生，Emacs 会定期将正在编<br>辑的文件写入一个&#8220;自动保存&#8221;文件中。自动保存文件的文件名的头尾各有一个<br>&#8220;#&#8221;字符，比如你正在编辑的文件叫&#8220;hello.c&#8221;，那么它的自动保存文件就叫<br>&#8220;#hello.c#&#8221;。这个文件会在正常存盘之后被 Emacs 删除。<br><br>所以，假如不幸真的发生了，你大可以从容地打开原来的文件（注意不是自动保<br>存文件）然后输入 M-x recover file&lt;Return&gt; 来恢复你的自动保存文件。在提<br>示确认的时候，输入 yes&lt;Return&gt;。<br><br><br>* 回显区（ECHO AREA）<br>---------------------<br><br>如果 Emacs 发现你输入多字符命令的节奏很慢，它会在窗格的下方称为&#8220;回显区&#8221;<br>的地方给你提示。回显区位于屏幕的最下面一行。<br><br><br>* 状态栏（MODE LINE）<br>---------------------<br><br>位于回显区正上方的一行被称为&#8220;状态栏&#8221;。状态栏上会显示一些信息，比如：<br><br>--:**&nbsp; TUTORIAL.cn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (Fundamental)--L670--54%----------------<br><br>状态栏显示了 Emacs 的状态和你正在编辑的文字的一些信息。<br><br>你应该知道文件名的意思吧？就是你找到的那个文件嘛。-NN%-- 显示的是光标在<br>全文中的位置。如果位于文件的开头，那么就显示 --Top-- 而不是 --00%--；如<br>果位于文件的末尾，就显示 --Bot--。如果文件很小，一屏就足以显示全部内容，<br>那么状态栏会显示 --All--。<br><br>&#8220;L&#8221; 和其后的数字给出了光标所在行的行号。<br><br>最开头的星号（*）表示你已经对文字做过改动。刚刚打开的文件肯定没有被改动<br>过，所以状态栏上显示的不是星号而是短线（-）。<br><br>状态栏上小括号里的内容告诉你当前正在使用的编辑模式。缺省的模式是<br>Fundamental，就是你现在正在使用的这个。它是一种&#8220;主模式&#8221;。<br><br>Emacs 的主模式林林总总。有用来编辑程序代码的――比如 Lisp 模式；也有用<br>来编辑各种自然语言文本的――比如 Text 模式。任何情况下只能应用一个主模<br>式，其名称会显示在状态栏上，也就是现在显示&#8220;Fundamental&#8221;的地方。<br><br>主模式通常会改变一些命令的行为。比方说，不管编辑什么语言的程序代码，你<br>都可以用一个相同的命令来添加注释。但是在不同的语言中注释的语法往往是不<br>同的，这时不同的主模式就会用各自不同的语法规则来添加注释。主模式都是可<br>以用 M-x 启动的扩展命令，M-x fundamental-mode 就可以切换到 Fundamental<br>模式。<br><br>编辑自然语言文本――比如现在――应该用 Text 模式。<br><br>&gt;&gt; 输入 M-x text mode&lt;Return&gt;。<br><br>别担心，什么都没变。不过细心一些可以发现，M-f 和 M-b 现在把单引号（'）<br>视为词的一部分了。而在先前的 Fundamental 模式中，M-f 和 M-b 都将单引号<br>视为分隔单词的符号。<br><br>主模式通常都会搞一些类似的小动作，因为很多命令其实完成的是&#8220;相同的工<br>作&#8221;，只是在不同环境下会有不同的工作方式而已。【所谓&#8220;求同存异&#8221;，在<br>Emacs 里得到了很好的体现】<br><br>用 C-h m 可以查看当前主模式的文档。<br><br>&gt;&gt; 用 C-u C-v 将本行带到屏幕的最上方。<br>&gt;&gt; 输入 C-h m，看看 Text 模式与 Fundamental 模式有哪些不同。<br>&gt;&gt; 输入 C-x 1 关掉文档窗格。<br><br>主模式之所以称之为&#8220;主（major）&#8221;模式，是因为同时还有&#8220;辅模式&#8221;（minor<br>mode）存在。辅模式并不能替代主模式，而是提供一些辅助的功能。每个辅模式<br>都可以独立地开启和关闭，跟其它辅模式无关，跟主模式也无关。所以你可以不<br>使用辅模式，也可以只使用一个或同时使用多个辅模式。<br><br>有一个叫做自动折行（Auto Fill）的辅模式很有用，特别是在编辑自然语言文本<br>的时候。启用自动折行后，Emacs 会在你打字超出一行边界时自动替你换行。<br><br>用 M-x auto fill mode&lt;Return&gt; 启动自动折行模式。再用一次这条命令，自动<br>折行模式会被关闭。也就是说，如果自动折行模式没有被开启，这个命令会开启<br>它；如果已经开启了，这个命令会关闭它。所以我们说，这个命令可以用来&#8220;开<br>关（toggle）&#8221;模式。<br><br>&gt;&gt; 现在输入 M-x auto fill mode&lt;Return&gt;。然后随便敲点什么，直到你看到它<br>&nbsp;&nbsp; 分成两行。你必须敲一些空格，因为 Auto Fill 只在空白处进行断行。<br>&nbsp;&nbsp; 【输入空格对英文来说是必须的，而对中文则不必。】<br><br>行边界通常被设定为 70 个字符【这里指英文字符】，你可以用 C-x f 命令配合<br>数字参数来重新设定它。<br><br>&gt;&gt; 输入 C-x f 并传递参数 20： C-u 2 0 C-x f。<br>&nbsp;&nbsp; 然后输入一些文字，观察 Emacs 的自动折行动作<br>&nbsp;&nbsp; 最后再用 C-x f 将边界设回 70。<br><br>如果你在段落的中间做了一些修改，那么自动折行模式不会替你把整个段落重新<br>折行，你需要用 M-q 手动折行。注意，光标必须位于你需要折行的那一段里。<br><br>&gt;&gt; 移动光标到前一段中，然后输入 M-q。<br><br><br>* 搜索（SEARCHING）<br>-------------------<br><br>Emacs 可以向前或向后搜索字符串。搜索命令是一个移动光标的命令：搜索成功<br>后，光标会停留在搜索目标出现的地方。<br><br>Emacs 的搜索命令的独特之处在于，它是&#8220;渐进的（incremental）&#8221;。意思是搜<br>索与输入同时进行：你在键盘上一字一句地输入搜索词的过程中，Emacs 就已经<br>开始替你搜索了。<br><br>C-s 是向前搜索，C-r 是向后搜索。不过手别这么快！别着急试。<br><br>在按下 C-s 之后，回显区里会有&#8220;I-search&#8221;字样出现，表明目前 Emacs 正处<br>于&#8220;渐进搜索&#8221;状态，并等待你输入搜索字串。按 &lt;Return&gt; 可以结束搜索。<br><br>&gt;&gt; 输入 C-s 开始一个搜索。注意敲慢一点，一次输入一个字符。<br>&nbsp;&nbsp; 慢慢输入&#8220;cursor&#8221;这个词，每敲一个字都停顿一下并观察光标。<br>&nbsp;&nbsp; 现在你应该已曾经找到&#8220;cursor&#8221;这个词了。<br>&gt;&gt; 再按一次 C-s，搜索下一个&#8220;cursor&#8221;出现的位置。<br>&gt;&gt; 现在按四次退格键，看看光标是如何移动的。<br>&gt;&gt; 敲 &lt;Return&gt; 结束搜索。<br><br>看仔细了么？在一次渐进式搜索中，Emacs 会尝试跳到搜索目标出现的位置。要<br>跳到下一个命中位置，就再按一次 C-s。如果找不到目标，Emacs 会发出&#8220;哔&#8221;<br>的一声，告诉你搜索失败。在整个过程中，都可以用 C-g 来终止搜索。【你会发<br>现 C-g 会让光标回到搜索开始的位置，而 &lt;Return&gt; 则让光标留在搜索结果上，<br>这是很有用的功能。】<br><br>注意：在某些终端下，输入 C-x C-s 会冻结屏幕【屏幕没有任何输出】，使你看<br>不到 Emacs 的任何变化。其原因是操作系统的&#8220;流量控制&#8221;功能拦截了 C-s 并<br>冻结了屏幕。用 C-q 可以解除屏幕冻结。要解决这个问题，请参考 Emacs 手册<br>里的&#8220;Spontaneous Entry to Incremental Search&#8221;一节【Emacs 手册可能还没<br>有中文翻译】，那里提供了一些有用的建议。<br><br>在渐进式搜索中，按退格键会删除目标字符串的最后一个字符，并且光标会回到<br>最近一次搜索的命中位置。比如你已经输入了&#8220;c&#8221;，光标就停在&#8220;c&#8221;第一次出<br>现的位置，再输入&#8220;u&#8221;，光标停在&#8220;cu&#8221;第一次出现的位置，这时再按退格键，<br>&#8220;u&#8221;就从搜索字串中消失了，然后光标会回到&#8220;c&#8221;第一次出现的位置。<br><br>另外，如果你在搜索的时候输入了 CONTROL 或者 META 组合键的话，搜索可能会<br>结束。（也有例外，比如 C-s 和 M-r 这些用于搜索的命令。）<br><br>前面说的都是&#8220;向下&#8221;搜索，如果想&#8220;向上&#8221;搜索，可以用 C-r。C-r 与 C-s<br>相比除了搜索方向相反之外，其余的操作都一样。<br><br><br>* 多窗格（MULTIPLE WINDOWS）<br>----------------------------<br><br>Emacs 的迷人之处很多，能够在屏幕上同时显示多个窗格就是其中之一。<br><br>&gt;&gt; 移动光标到这一行，然后输入 C-u 0 C-l。<br><br>&gt;&gt; 现在输入 C-x 2，它会将屏幕划分成两个窗格。<br>&nbsp;&nbsp; 这两个窗格里显示的都是本篇快速指南，而光标则停留在上方的窗格里。<br><br>&gt;&gt; 试试用 C-M-v 滚动下方的窗格。<br>&nbsp;&nbsp; （如果你并没有 META 键，用 ESC C-v 也可以。）<br>&nbsp;&nbsp; 【向上滚动是 C-M-S-v，也就是同时按住 CONTROL、META 和 SHIFT 再按 v】<br><br>&gt;&gt; 输入 C-x o（&#8220;o&#8221;指的是&#8220;其它（other）&#8221;），<br>&nbsp;&nbsp; 将光标转移到下方的窗格。<br><br>&gt;&gt; 在下方的窗格中，用 C-v 和 M-v 来滚动。<br>&nbsp;&nbsp; 同时继续在上方的窗格里阅读这些指导。<br><br>&gt;&gt; 再输入 C-x o 将光标移回到上方的窗格里。<br>&nbsp;&nbsp; 光标会回到它在上方窗格中原本所在的位置。<br><br>连续使用 C-x o 可以遍历所有窗格。每一个窗格都有它自己的光标位置，但是只<br>有一个窗格会真正显示这个光标。【其它窗格在控制台下不会显示光标，在图形<br>窗口下缺省显示为镂空光标。】一般所有的编辑命令都作用于这个光标所在的窗<br>格，我们称这个窗格为&#8220;被选中的窗格&#8221;。<br><br>当你在一个窗格中编辑，但用另一个窗格作为参考的时候，C-M-v 是很有用的命<br>令。你可以始终处于编辑窗格中，然后用 C-M-v 命令滚动另外一个窗格。【比如<br>翻译和校对就很适合用这种方式进行。】<br><br>C-M-v 是一个 CONTROL-META 组合键。如果你有 META 键的话，可以同时按住<br>CONTROL 和 META 键并输入 v。CONTROL 和 META 键先按哪个都可以，因为它们<br>只是用来&#8220;修饰（modify）&#8221;你输入的字符的。<br><br>如果你并没有 META 键，你也可以用 ESC 来代替，不过这样的话就要注意按键顺<br>序了：你必须先输入 ESC ，然后再输入 CONTROL-v。CONTROL-ESC v 是没用的，<br>因为 ESC 本身是一个字符键，而不是一个修饰键（modifier key）。<br><br>&gt;&gt; （在上方窗格里）输入 C-x 1 关掉下方窗格。<br><br>（如果你在下方的窗格里输入 C-x 1，那么就会关掉上方的窗格。你可以把这个<br>命令看成是&#8220;只保留一个窗格&#8221;――就是我们正在编辑的这个。）<br><br>不同的窗格可以显示不同的缓冲区。如果你在一个窗格里用 C-x C-f 打开了一个<br>文件，另一个窗格并不会发生什么变化。任何一个窗格里都可以用来打开文件。<br><br>用下面的方法可以在一个新开窗格里打开文件：<br><br>&gt;&gt; 输入 C-x 4 C-f，紧跟着输入一个文件名，再用 &lt;Return&gt; 结束。<br>&nbsp;&nbsp; 可以看到你指定的文件出现在下方的窗格中，同时光标也跳到了那里。<br><br>&gt;&gt; 输入 C-x o 回到上方的窗格，然后再用 C-x 1 关掉下方窗格。<br><br><br>* 递归编辑（RECURSIVE EDITING LEVELS）<br>--------------------------------------<br><br>有时候你会进入所谓的&#8220;递归编辑&#8221;。递归编辑状态由位于状态栏的方括号所指<br>示，其中包含了用小括号来指明的模式名称。比如说，你有时可能会看到<br>[(Fundamental)]，而不是 (Fundamental)。【比如在用 M-% 进行交互式替换的<br>时候你又用了 C-s 进行搜索，这时替换模式并没有结束，但你又进入了搜索模式，<br>这就是所谓的递归编辑。】<br><br>离开递归编辑可以用 ESC ESC ESC。这是一个最通用的&#8220;离开&#8221;命令，你甚至可<br>以使用它来关掉多余的窗格，或者离开小缓冲。<br><br>&gt;&gt; 输入 M-x 进入小缓冲；然后输入 ESC ESC ESC 离开。<br><br>你不能用 C-g 退出递归编辑，因为 C-g 的作用是取消&#8220;本层递归编辑之内&#8221;的<br>命令和其参数（arguments）。<br><br><br>* 获得更多帮助（GETTING MORE HELP）<br>-----------------------------------<br><br>本快速指南的目的仅仅是帮助你在 Emacs 的海洋里下水，不至于束手无策望洋兴<br>叹。有关 Emacs 的话题可谓汗牛充栋，这里自然是难尽万一。不过 Emacs 很理<br>解你求知若渴的心情，因为它提供的强大功能实在是太多了。为此，Emacs 提供<br>了一些命令来查看 Emacs 的命令文档，这些命令都以 CONTROL-h 开头，这个字<br>符也因此被称为&#8220;帮助（Help）字符&#8221;。<br><br>要使用帮助（Help）功能，请先输入 C-h，然后再输入一个字符以说明你需要什<br>么帮助。如果你连自己到底需要什么帮助都不知道，那么就输入 C-h ?，Emacs<br>会告诉你它能提供了哪些帮助。如果你按了 C-h 又想反悔，可以用 C-g 取消。<br><br>（有些主机改变了 C-h 的意义，这种以己度人外加一刀切的做法确实不太好，不<br>过倒是让你可以义正辞严地抱怨他们的系统管理员。话说回来，如果你按 C-h 之<br>后没有任何帮助信息显示出来，那么试试 F1 键或者 M-x help &lt;Return&gt; 。）<br><br>最基本的帮助功能是 C-h c。输入 C-h c 之后再输入一个组合键，Emacs 会给出<br>这个命令的简要说明。<br><br>&gt;&gt; 输入 C-h c C-p。<br><br>显示的消息应该会是这样：<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C-p runs the command previous-line<br><br>这条消息显示了 C-p 命令对应的函数名，函数名主要用来定制和扩展 Emacs。命<br>令的功能由函数完成，所以函数名本身也可以被看成是最简单的文档――至少对<br>于你已经学过的命令来说，它们的函数名足以解释它们的功能了。<br><br>多字符命令一样可以用 C-h c 来查看。<br><br>想得到更多的信息，请把 C-h c 换成 C-h k 试试看。<br><br>&gt;&gt; 输入 C-h k C-p。<br><br>上面的命令会新打开一个 Emacs 窗格以显示函数的名称及其文档。你读完之后可<br>以用 C-x 1 关掉这个帮助窗格。当然你并不需要立即这样做，你完全可以先在编<br>辑窗格里做点别的事情，然后再关掉帮助窗格。<br><br>还有一些其它有用的 C-h 命令：<br><br>&nbsp;&nbsp; C-h f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 解释一个函数。需要输入函数名。<br><br>&gt;&gt; 试试看，输入 C-h f previous-line&lt;Return&gt;。<br>&nbsp;&nbsp; Emacs 会给出它所知道的所有有关&#8220;实现 C-p 命令功能的函数&#8221;的信息。<br><br>C-h v 用来显示 Emacs 变量的文档。Emacs 变量可以被用来&#8220;定制 Emacs 的行<br>为&#8221;。同样，你需要输入变量的名称。<br><br>&nbsp;&nbsp; C-h a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 相关命令搜索（Command Apropos）。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 输入一个关键词然后 Emacs 会列出所有命令名中包含此关键词<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 的命令。这些命令全都可以用 M-x 来启动。对于某些命令来说，<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 相关命令搜索还会列出一两个组合键。<br><br>&gt;&gt; 输入 C-h a file&lt;Return&gt;。<br><br>Emacs 会在另一个窗格里显示一个 M-x 命令列表，这个列表包含了所有名称中含<br>有&#8220;file&#8221;的命令。你可以看到像&#8220;C-x C-f&#8221;这样的组合键显示在&#8220;find-file&#8221;<br>这样的命令名的旁边。<br><br>&gt;&gt; 用 C-M-v 来回滚动 help 窗格，多试几次。<br><br>&gt;&gt; 输入 C-x 1 来删除 help 窗格。<br><br>&nbsp;&nbsp; C-h i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 阅读联机手册（也就是通常讲的 Info）。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这个命令会打开一个称为&#8220;*info*&#8221;的特殊缓冲区，在那里，<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 你可以阅读安装在系统里的软件包使用手册。要读 Emacs 的使<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用手册，按 m emacs &lt;Return&gt; 就可以了。如果你之前从没用<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 过 Info 系统，那么请按&#8220;?&#8221;，Emacs 会带你进入 Info 的使<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用指南。在看完本快速指南之后，Emacs Info 会成为你的主要<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 参考文档。<br><br><br>* 更多精彩（MORE FEATURES）<br>---------------------------<br><br>想学习更多的使用技巧，Emacs 使用手册（manual）值得一读。你可以读纸版的<br>书，也可以看电子版的联机手册（可以从 Help 菜单进入或者按 F10 h r）。提<br>两个你可能会很感兴趣的功能吧，一个是可以帮你少敲键盘的 completion（自动<br>补全），另一个是方便文件处理的 dired（目录编辑）。<br><br>Completion 可以替你节省不必要的键盘输入。比如说你想切换到 *Message* 缓<br>冲区，你就可以用 C-x b *M&lt;Tab&gt; 来完成。只要 Emacs 能够根据你已经输入的<br>文字确定你想要输入的内容，它就会自动帮你补齐。有关 Completion 的详细说<br>明可以在 Emacs Info 中的&#8220;Completion&#8221;一节里找到。<br><br>Dired 能够在一个缓冲区里列出一个目录下的所有文件（可以选择是否也列出子<br>目录），然后你可以在这个文件列表上完成对文件的移动、访问、重命名或删除<br>等等操作。Dired 也在 Emacs Info 中有详细介绍，参见&#8220;Dired&#8221;一节。<br><br>Emacs 使用手册里还有许许多多的精彩功能等着你来了解。<br><br><br>* 总结（CONCLUSION）<br>--------------------<br><br>记住，要退出 Emacs 请用 C-x C-c。要暂时切换到 shell 并且稍后再回到<br>Emacs 里来，请用 C-z。【切换到 shell 仅对控制台下的 Emacs 有效】<br><br>本文完全是为零起点新手所写的起步教程。如果你觉得哪里还看不明白，千万不<br>要怀疑自己，那一定是我们没有写好。我们永远欢迎你的不满和抱怨。<br><br><br>* 翻译（TRANSLATION）<br>---------------------<br><br>翻译：孙一江 &lt;sunyijiang@gmail.com&gt;<br>校对：水木社区（www.newsmth.net）Emacs 板众多网友及众多 Emacs 中文用户<br><br>Emacs 快速指南（Tutorial）早有两个刘昭宏的中文译本，繁简各一。其简体版本<br>（TUTORIAL.cn）基本由繁体版本（TUTORIAL.zh）经词语替换而得。然而繁简中文<br>不仅在用词习惯上有所不同，更有诸多表达方式与句法方面的差异，因此一直以来<br>用户使用 TUTORIAL.cn 都会略觉生硬和晦涩。这次重新翻译 TUTORIAL.cn 的动机<br>正是源于这种体验，希望我们的工作能够让本文更好地发挥其作用。TUTORIAL.zh<br>的译文质量很高，在翻译过程中给予过我们许多借鉴和参考，在此对刘昭宏的工作<br>表示感谢。<br><br>翻译过程中最大的挑战莫过于术语译词的选择了。经过水木社区 Emacs 板热心网<br>友小范围内的讨论，我们选择了现在的译法。用户的广泛参与是自由软件生命力<br>的源泉，所以如果你有任何建议、勘误或想法，请用你喜欢的方式向我们提出。<br>你可以通过电子邮件直接联系译者，也可以放到 GNU Emacs 的开发邮件列表或者<br>水木社区的 Emacs 板上进行讨论。<br><br>下面列出主要术语的译词对照，并给出注释说明：<br><br>&nbsp;&nbsp;&nbsp; command&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 命令<br>&nbsp;&nbsp;&nbsp; cursor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 光标<br>&nbsp;&nbsp;&nbsp; scrolling&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 滚动<br>&nbsp;&nbsp;&nbsp; numeric argument&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 数字参数<br>&nbsp;&nbsp;&nbsp; window&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 窗格 [1]<br>&nbsp;&nbsp;&nbsp; insert&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 插入<br>&nbsp;&nbsp;&nbsp; delete&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 删除 [2]<br>&nbsp;&nbsp;&nbsp; kill&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 移除 [2]<br>&nbsp;&nbsp;&nbsp; yank&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 召回 [2]<br>&nbsp;&nbsp;&nbsp; undo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 撤销<br>&nbsp;&nbsp;&nbsp; file&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 文件<br>&nbsp;&nbsp;&nbsp; buffer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 缓冲区<br>&nbsp;&nbsp;&nbsp; minibuffer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 小缓冲<br>&nbsp;&nbsp;&nbsp; echo area&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 回显区<br>&nbsp;&nbsp;&nbsp; mode line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 状态栏<br>&nbsp;&nbsp;&nbsp; search&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 搜索<br>&nbsp;&nbsp;&nbsp; incremental search&nbsp;&nbsp;&nbsp; 渐进式搜索 [3]<br><br>[1] &#8220;window&#8221;一词在计算机相关的领域一般都被译为&#8220;窗口&#8221;。但是在 Emacs<br>&nbsp;&nbsp;&nbsp; 中，还有一个&#8220;frame&#8221;的概念。在被广泛使用的 X 窗口系统和微软的视窗<br>&nbsp;&nbsp;&nbsp; （Windows）系列操作系统中，Emacs 的一个&#8220;frame&#8221;就是一个&#8220;窗口&#8221;，因<br>&nbsp;&nbsp;&nbsp; 此把 Emacs 中的&#8220;frame&#8221;译成&#8220;窗口&#8221;更加符合通常的习惯。这样，Emacs<br>&nbsp;&nbsp;&nbsp; 中的&#8220;window&#8221;就只能译成&#8220;窗格&#8221;了。我们认为 Emacs 中 window 和<br>&nbsp;&nbsp;&nbsp; frame 的关系用窗格和窗口来类比是十分形象的。<br><br>&nbsp;&nbsp;&nbsp; 《学习GNU Emacs》（第二版）一书对&#8220;window&#8221;和&#8220;frame&#8221;的翻译与本教程<br>&nbsp;&nbsp;&nbsp; 刚好相反（分别译作&#8220;窗口&#8221;和&#8220;窗格&#8221;）。在此特别注明，以消除可能产生<br>&nbsp;&nbsp;&nbsp; 的疑惑。（感谢李旭章 &lt;lixuzhang@gmail.com&gt; 指出）<br><br>[2] 对于&#8220;delete&#8221;和&#8220;kill&#8221;的区别，正文已经给出了详细的说明。&#8220;删除&#8221;和<br>&nbsp;&nbsp;&nbsp; &#8220;移除&#8221;相比较起来，前者更多地隐含着&#8220;破坏&#8221;和&#8220;不可恢复&#8221;的意思，而<br>&nbsp;&nbsp;&nbsp; 后者更多地隐含着&#8220;被转移&#8221;和&#8220;可恢复&#8221;的意思。因此分别选择它们作为上<br>&nbsp;&nbsp;&nbsp; 述两词的译词，希望能够体现出区别。&#8220;yank&#8221;在中文文档中鲜有对应译词出<br>&nbsp;&nbsp;&nbsp; 现，翻译的困难较大。究其本意是：&#8220;a strong sudden pull&#8221;（参见韦氏词<br>&nbsp;&nbsp;&nbsp; 典），即&#8220;猛然拉回&#8221;。在原文档中 yank 被引申为&#8220;将先前移除的东西再移<br>&nbsp;&nbsp;&nbsp; 回来&#8221;这个意思，所以我们选择了&#8220;召回&#8221;一词与其对应。<br><br>[3] &#8220;incremental&#8221;一词在计算机著作中广泛出现，被广泛接受的中文译词有两<br>&nbsp;&nbsp;&nbsp; 个：&#8220;增量的&#8221;和&#8220;渐进的&#8221;。&#8220;incremental search&#8221;翻译成&#8220;增量式搜索<br>&nbsp;&nbsp;&nbsp; &#8221;或者&#8220;渐进式搜索&#8221;都讲得通，且都有各自的形象之处。还是参考原文对其<br>&nbsp;&nbsp;&nbsp; 的解释：&#8220;... means that the search happens while you type in the<br>&nbsp;&nbsp;&nbsp; string to search for&#8221;。意思是之所以称其为&#8220;incremental search&#8221;，是<br>&nbsp;&nbsp;&nbsp; 因为&#8220;在你输入搜索字符串的过程中，搜索就已经在进行了&#8221;。我们认为&#8220;增<br>&nbsp;&nbsp;&nbsp; 量的&#8221;更加强调在现有基础上的变化（比如&#8220;增量备份&#8221;，&#8220;增量编译&#8221;）；<br>&nbsp;&nbsp;&nbsp; 而&#8220;渐进的&#8221;更加强调过程的逐渐发展，也更加符合原文的意思。因此我们选<br>&nbsp;&nbsp;&nbsp; 择将&#8220;incremental search&#8221;译作&#8220;渐进式搜索&#8221;。<br><br><br>* 版权声明（COPYING）<br>---------------------<br><br>This tutorial descends from a long line of Emacs tutorials<br>starting with the one written by Stuart Cracraft for the original Emacs.<br><br>This version of the tutorial, like GNU Emacs, is copyrighted, and<br>comes with permission to distribute copies on certain conditions:<br><br>Copyright (C) 1985, 1996, 1998, 2001, 2002, 2003, 2004,<br>&nbsp;&nbsp; 2005, 2006, 2007&nbsp; Free Software Foundation, Inc.<br><br>&nbsp;&nbsp; Permission is granted to anyone to make or distribute verbatim copies<br>&nbsp;&nbsp; of this document as received, in any medium, provided that the<br>&nbsp;&nbsp; copyright notice and permission notice are preserved,<br>&nbsp;&nbsp; and that the distributor grants the recipient permission<br>&nbsp;&nbsp; for further redistribution as permitted by this notice.<br><br>&nbsp;&nbsp; Permission is granted to distribute modified versions<br>&nbsp;&nbsp; of this document, or of portions of it,<br>&nbsp;&nbsp; under the above conditions, provided also that they<br>&nbsp;&nbsp; carry prominent notices stating who last altered them.<br><br>The conditions for copying Emacs itself are more complex, but in the<br>same spirit.&nbsp; Please read the file COPYING and then do give copies of<br>GNU Emacs to your friends.&nbsp; Help stamp out software obstructionism<br>("ownership") by using, writing, and sharing free software!<br><br>【下面为版权声明的译文，仅供参考。实际法律效力以英文原文为准。】<br><br>本快速指南沿袭自历史悠久的 Emacs 快速指南，可上溯至 Stuart Cracraft 为最<br>初的 Emacs 所作的版本。<br><br>本篇文档与 GNU Emacs 一样拥有版权，并允许在下列条件的约束下发行其拷贝：<br><br>&nbsp;&nbsp; Copyright (C) 1985, 1996, 1998, 2001, 2002, 2003, 2004, 2005, 2006,<br>&nbsp;&nbsp; 2007&nbsp; Free Software Foundation, Inc.<br><br>&nbsp;&nbsp; 本文档允许在不变更文档内容的情况下由任何人发布在任何媒体上，同时必须<br>&nbsp;&nbsp; 完整保留版权和许可声明，且需给予受众与发行者完全相同的、如本声明所允<br>&nbsp;&nbsp; 许的再次发行本文档的权利。<br><br>&nbsp;&nbsp; 本声明允许在与上述条件相同的情况下发布经过修改的全部或部分文档，同时<br>l&nbsp;&nbsp; 必须附带显要的文字以申明文档的最后修改者。<br><br>Emacs 自身的版权问题虽比本文档要复杂一些，但也基于相同的精神。敬请阅读文<br>件&#8220;COPYING&#8221;，然后向你的朋友们分发 GNU Emacs 拷贝。让我们以使用、编写和<br>分享自由软件的实际行动来共同祛除软件障碍主义（所谓的&#8220;所有权&#8221;）！<br><br>;;; Local Variables:<br>;;; coding: chinese-iso-8bit<br>;;; End:<br><br>;;; arch-tag: 46a53d82-a85a-46b6-bdc7-583aca063578<br><br>
<br><img src ="http://www.cppblog.com/DrMagic/aggbug/37149.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DrMagic/" target="_blank">Dr.Magic</a> 2007-11-22 17:53 <a href="http://www.cppblog.com/DrMagic/archive/2007/11/22/37149.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VIM-Project Plugin</title><link>http://www.cppblog.com/DrMagic/archive/2007/11/19/36964.html</link><dc:creator>Dr.Magic</dc:creator><author>Dr.Magic</author><pubDate>Mon, 19 Nov 2007 11:11:00 GMT</pubDate><guid>http://www.cppblog.com/DrMagic/archive/2007/11/19/36964.html</guid><wfw:comment>http://www.cppblog.com/DrMagic/comments/36964.html</wfw:comment><comments>http://www.cppblog.com/DrMagic/archive/2007/11/19/36964.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DrMagic/comments/commentRss/36964.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DrMagic/services/trackbacks/36964.html</trackback:ping><description><![CDATA[花了点时间翻译出来，有些地方还不是很清晰明了，主要是有些功能还尚未使用。下载 <a style="color: #ff0030;" title="project中文帮助" href="http://tel6.800disk.com/??5403">project中文帮助</a>（也
可以将下文保存成project.txt文件）放到vim的doc目录中，覆盖原来的英文帮助。如果你不想覆盖，你可以把原来的帮助文件移动到上层目录或
其他地方，注意不要重命名放在doc目录下，不然在使用helptags doc目录产生tags时会提示tag重复的警告信息。以后使用: help
project 出来的就是中文手册了。时间仓促，翻译的不好，不当或错误之处敬请各位看官指出来。<br><br>*project.txt* &nbsp;&nbsp;&nbsp; 一个用来管理多个项目及项目源代码的插件<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 支持版本: Vim 6.x 及 Vim7.x<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 最后更新: 2006 年 10 月 13 日 星期五<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 翻译更新: 2007 年 08 月 16 日 星期五<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 作者：Aric Blumer<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 译者：Denven<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; *project* *project-plugin*<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 目录：<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 1.命令..............调出插件.............|project-invoking|<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 2.继承...........项目层层关系.........|project-inheritance|<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 3.映射.............插件映射..............|project-mappings|<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 4.添加映射.......为插件添加映射...|project-adding-mappings|<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 5.设置..............项目设置.............|project-settings|<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 6.样例文件..........项目样例..............|project-example|<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 7.技巧..............使用技巧.................|project-tips|<br style="color: #0846ff;">
&nbsp;<br style="color: #0846ff;">
<br style="color: #0846ff;">
使用这个插件的基本功能可以为你经常访问的文件提供方便的浏览. 文件会在 Vim 左侧<br style="color: #0846ff;">
窗口列出来, 在文件名上按 &lt;Return&gt; 或者双击鼠标就可以打开相应的文件. 这比使用<br style="color: #0846ff;">
|file-explorer| 去浏览多层目录要更为便捷.<br style="color: #0846ff;">
<br style="color: #0846ff;">
也可在选择一个文件时候去让插件更改目录, 执行指定都 Vim 脚本. 这些脚本可以通过<br style="color: #0846ff;">
修改 $PATH 来设定编译器等的环境. 这在进行多项目开发时可以让 quickfix 工作在不<br style="color: #0846ff;">
同的环境中.<br style="color: #0846ff;">
<br style="color: #0846ff;">
其他特性:<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; o 在项目中实时加载或卸载文件(\l, \L, \w, and \W)<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; o 在项目中所有文件进行全局搜索(\g and \G)<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; o 对某一个文件单独执行用户指定的脚本(可以利用这个特写来关联一个文件到<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp; 某一个外部程序) (使用\1 到 \9)<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; o 对所有文件执行某个用户指定的脚本(使用\f1-\f9 和 \F1-\F9)<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; o 用户高可定制性<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; o 可以配合 |netrw| 插件使用 XXXX://... 管理远程项目. XXXX 代表 ftp, <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp; rcp, scp, or http.<br style="color: #0846ff;">
<br style="color: #0846ff;">
可以在一个单独的纯本文件中或在 vimrc 中设置几个全局量变进行配置.<br style="color: #0846ff;">
<br style="color: #0846ff;">
必须在 |vimrc| 文件中 set 'nocompatible' 才能使用这个插件. 也可以通过设置变量<br style="color: #0846ff;">
"loaded_project" 来禁止插件被加载: &gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; :let loaded_project = 1<br style="color: #0846ff;">
<br style="color: #0846ff;">
<br style="color: #0846ff;">
==============================================================================<br style="color: #0846ff;">
COMMANDS&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *project-invoking*<br style="color: #0846ff;">
<br style="color: #0846ff;">
要使用本插件, 只需将其放置到 Vim 的插件目录(~/.vim/plugin)即可. 参见<br style="color: #0846ff;">
"|add-global-plugin|", 在下次打开 Vim 时, 输入如下命令 &gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; :Project<br style="color: #0846ff;">
或者 &gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; :Project {file}<br style="color: #0846ff;">
<br style="color: #0846ff;">
如果没有指定具体的项目文件, 那么会默认使用$HOME/.vimprojects文件.<br style="color: #0846ff;">
<br style="color: #0846ff;">
命令: [g]vim +Project 可在 Vim 启动时同时自动载入project插件窗口.<br style="color: #0846ff;">
<br style="color: #0846ff;">
调出项目窗口时每次只能使用某一个文件, 如果想更改项目, 在项目窗口中运行:bwipe <br style="color: #0846ff;">
删除项目缓冲, 然后用 :Project {file} 重新载入新的项目.<br style="color: #0846ff;">
<br style="color: #0846ff;">
<br style="color: #0846ff;">
可以在同一个文件中保留和显示多个项目, 通过 {} (c参见 |fold.txt|) 来分隔. 在项目<br style="color: #0846ff;">
中可以有任意多个嵌套的折叠. {} 中的每一行被当作一个文件名. 空行和 # 号后面的内<br style="color: #0846ff;">
容将被忽略.<br style="color: #0846ff;">
<br style="color: #0846ff;">
插件使用 Vim 标准的折叠方式, 支持所有的 |fold-commands| . 例如双击折叠的首行可<br style="color: #0846ff;">
以打开或关闭该折叠. 通过光标定位到一个文件名后按回车键或者双击即可打开该文件, <br style="color: #0846ff;">
插件会为在右侧打开一个新窗口来显示(如果映射了 |CTRL-W_p|, 也是等价的).<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *project-syntax*<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *语法*<br style="color: #0846ff;">
项目入口描述形式:<br style="color: #0846ff;">
project_entry ::=<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &lt;Description&gt;={projpath} [{options}] {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; [ filename ]<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; [ project_entry ]<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; }<br style="color: #0846ff;">
<br style="color: #0846ff;">
{options} 可以是下面的一项或者几项, 但必须放在同一行上.<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; CD={path}<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; in={filename}<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; out={filename}<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; filter="{pat}"<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; flags={flag}<br style="color: #0846ff;">
<br style="color: #0846ff;">
注意: 一个项目入口可以包含在另一个项目入口里面,&nbsp;&nbsp;&nbsp; 这意味着可以在项目中设置层次关系.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;Description&gt; 项目描述. 不能含有"="字符. 在 =. 的两边不能有空字符. 它会显示在折叠<br style="color: #0846ff;">
行上.<br style="color: #0846ff;">
<br style="color: #0846ff;">
{projpath} 项目路径. 它指向项目文件所在目录, 可以在里面使用环境变量. 如果是一个相<br style="color: #0846ff;">
对路径, 插件会根据项目的父目录及其上层目录等层次建立路径, 但最外层的项目入口必须<br style="color: #0846ff;">
是一个绝对路径. 参见下面 |project-inheritance|的例子.可以在该项中使用空格, 但是要<br style="color: #0846ff;">
转义. 下面的两个例子是针对同一个目录的:<br style="color: #0846ff;">
&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Example=/my/directory/with\ spaces {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; }<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Example="/my/directory/with spaces" {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; }<br style="color: #0846ff;">
<br style="color: #0846ff;">
推荐在 Windows 上这样使用: &gt;<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Example="c:\My Documents" {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; }<br style="color: #0846ff;">
<br style="color: #0846ff;">
而 Vim 很聪明, 这样做也是可以的: &gt;<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Example=c:\My\ Documents {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; }<br style="color: #0846ff;">
<br style="color: #0846ff;">
CD= 表示在项目中选定一个文件时 Vim 将要进入的目录(相当于使用|:cd|). 这对在需要<br style="color: #0846ff;">
使用本地 Makefile 文件进行编译时, 如|:make| 非常有用. 使用 CD=. 表示 Vim 将<br style="color: #0846ff;">
{projpath} 及其等价路径设为当前工作目录. 如果不设置 CD 的值将无法中在项目中进<br style="color: #0846ff;">
行目录都切换, 注意 "=" 的两边没有空格. CD 参数也可以是来自其父目录下都一个相对<br style="color: #0846ff;">
路径. 参考 |project-inheritance| 中的例子. 在使用 |netrw| 浏览项目时该指令将被<br style="color: #0846ff;">
忽略. 在 {projpath} 中可以使用空格.<br style="color: #0846ff;">
<br style="color: #0846ff;">
in= 和 out= 用来在进入或者退出文件缓冲时执行特定的 Vim 脚本. (参考 |BufEnter| <br style="color: #0846ff;">
和 |BufLeave| 自动命令事件). 它可以使用 Vim 脚本来为项目设定或取消一定的环境.<br style="color: #0846ff;">
例如:<br style="color: #0846ff;">
<br style="color: #0846ff;">
in.vim: &gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; let $PROJECT_HOME='~/my_project'<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; " Put the compiler in $PATH<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; if $PATH !~ '/path/to/my/compiler'<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; let $PATH=$PATH.':/path/to/my/compiler'<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; endif<br style="color: #0846ff;">
<br style="color: #0846ff;">
out.vim: &gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; " Remove compiler from $PATH<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; if $PATH =~ '/path/to/my/compiler'<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; let $PATH=substitute($PATH, ':/path/to/my/compiler', '', 'g')<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; endif<br style="color: #0846ff;">
<br style="color: #0846ff;">
在这种情况下, 在合适的环境下可以使用 :make 进行编译你正在编辑的文件. 如果脚本中<br style="color: #0846ff;">
使用的是相对路径,&nbsp; If the path to the script is relative, then it is<br style="color: #0846ff;">
relative from {projpath}. <br style="color: #0846ff;">
如果子项目没有另行设定, 这些指令会被子项目继承. 当配合 |netrw| 插件使用时, in=<br style="color: #0846ff;">
和 out= 中的路径必须是绝对路径.<br style="color: #0846ff;">
<br style="color: #0846ff;">
filter= 过滤符. 它指定一个全局的 |glob()| 文件匹配模式. 用于在使用 \r 时更新项目<br style="color: #0846ff;">
窗口中的文件列表. 由于可能含有多个文件匹配模式, 必须使用双引号将过滤符号串扩起<br style="color: #0846ff;">
来. 如果不设置过滤符号, 插件默认使用通配符 * 来当做过滤符.注意"="前后不能含有空<br style="color: #0846ff;">
格. 如果子项目没有指定具体的过滤符, 子项目将会继承父项目的过滤符.<br style="color: #0846ff;">
<br style="color: #0846ff;">
flags= 标识位 为某个折叠设置(启用/取消)具体的特性. 为了记忆方便, 通常使用小写<br style="color: #0846ff;">
的表示关闭某一特性, 大写则表示开启某一特性. {flag} 参数可以使用下面的字符标志位:<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 标志位&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 描述 ~<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; l&nbsp;&nbsp;&nbsp; 关闭由 \L 的递归. 对于子折叠的同样也被关闭.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; r&nbsp;&nbsp;&nbsp; 关闭更新. 当对折叠使用了\r or \R 后不要进行更新. <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 它不影响子目录的递归.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; S&nbsp;&nbsp;&nbsp; 为刷新和创建项目开启排序功能.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; s&nbsp;&nbsp;&nbsp; 关闭刷新和创建项目的排序功能.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; T&nbsp;&nbsp;&nbsp; 开启更新项目时折叠处于当前折叠的正下方. 跟在全局变量 <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g:proj_flags 中使用标志位等效, 但是不能针对多个折叠而言.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; t&nbsp;&nbsp;&nbsp; 关闭更新项目时折叠至当前折叠区域的最顶部功能. 强制折叠到底部.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; w&nbsp;&nbsp;&nbsp; 关闭 \W 的递归. 对于子折叠的同样也被关闭.<br style="color: #0846ff;">
<br style="color: #0846ff;">
<br style="color: #0846ff;">
在子项目不能沿用父项目中设定的这些标志.<br style="color: #0846ff;">
<br style="color: #0846ff;">
只对当前折叠生效, 折叠外的文字不受其影响.<br style="color: #0846ff;">
<br style="color: #0846ff;">
<br style="color: #0846ff;">
==============================================================================<br style="color: #0846ff;">
INHERITANCE&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;*project-inheritance*<br style="color: #0846ff;">
<br style="color: #0846ff;">
通过下面两个项目文件的对比来理解层次的含义:<br style="color: #0846ff;">
&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Parent=~/my_project CD=. filter="Make* *.mk" flags=r {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;Child1=c_code {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;}<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;Child2=include CD=. filter="*.h" {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;}<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; }<br style="color: #0846ff;">
<br style="color: #0846ff;">
Child1 的路径是 "~/my_project/c_code", 因为 Child1 继承了 ~/my_project. 它还<br style="color: #0846ff;">
继承了 CD. 因为父层的 CD=., 所以对于父层的当前工作路径是 "~/my_project". 那么<br style="color: #0846ff;">
Child1 继承过来的 CD 也是"~/my_project". 最后, Child1 从父层继承过来过滤符. <br style="color: #0846ff;">
而标志位则是不能继承的,除非单独设置.<br style="color: #0846ff;">
<br style="color: #0846ff;">
Child2 只将 "~/my_project" 从父层继承过来.<br style="color: #0846ff;">
<br style="color: #0846ff;">
所以上述例子跟下面的展开是等价的:<br style="color: #0846ff;">
&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Parent=~/my_project CD=. filter="Make* *.mk" flags=r {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;Child1=~/my_project/c_code CD=~/my_project filter="Make* *.mk" {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;}<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;Child2=~/my_project/include CD=~/my_project/include filter="*.h" {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;}<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; }<br style="color: #0846ff;">
<br style="color: #0846ff;">
(在一个实际的项目中, Child1 一般不会希望从父层继承过滤符号, 该例子只是为了说明<br style="color: #0846ff;">
&nbsp;这个概念而已), 使用 \i 可以显示当前光标下项目的层次关系.<br style="color: #0846ff;">
<br style="color: #0846ff;">
<br style="color: #0846ff;">
==============================================================================<br style="color: #0846ff;">
MAPPINGS&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *project-mappings*<br style="color: #0846ff;">
<br style="color: #0846ff;">
映射&nbsp;&nbsp;&nbsp; 动作 ~<br style="color: #0846ff;">
<br style="color: #0846ff;">
\r&nbsp;&nbsp;&nbsp; 根据过滤符更新光标处的项目.&nbsp; 更新项目, 每深入一层折叠缩进一个空格.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 如果在一行最后使用了 "# pragma keep" (不含双引号), 那么该行将保留, <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 不会被在更新时被删除. 当使用 . 作为一个入口时, 进入当前目录进行浏览<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 相当方便, 通常对于这个有用的入口你肯定想在更新时被保留.<br style="color: #0846ff;">
&nbsp;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 注意这个映射是 &lt;LocalLeader&gt;r, Vim 默认使用 \ 作为|&lt;LocalLeader&gt;|.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 对于使用 |netrw| 浏览的项目不适用.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\R&nbsp;&nbsp;&nbsp; 递归执行 \r.<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 对于使用 |netrw| 浏览的项目不适用.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\c&nbsp;&nbsp;&nbsp; 创建一个项目. 要求用户输入 项目描述, 文件路径, CD 参数, 文件名匹配表达<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 式 |glob()|. 插件会根据这些信息在光标下面建立一个项目的入口.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 对于使用 |netrw| 浏览的项目不适用.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\C&nbsp;&nbsp;&nbsp; 为目录及其子目录下的文件递归创建一个项目.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;Return&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 在前一窗口或者另外一个新窗口中打开光标处的文件. 如果光标位于折叠上,<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 按此键打开或关闭折叠.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;S-Return&gt;<br style="color: #0846ff;">
\s<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 跟 &lt;Return&gt; 一样, 但会水平分割目标窗口.&nbsp;&nbsp;&nbsp; <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 使用 &lt;LocalLeader&gt;s 主要是为那些不能识别 &lt;S-Return&gt; 的终端而提供的.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\S<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 加载所有文件到当前窗口, 当前窗口会被水平分割显示所有文件.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;C-Return&gt;<br style="color: #0846ff;">
\o<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 同 &lt;Return&gt; 在一个窗口中打开当前文件, 同时关闭其他所有打开的窗口. <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 该映射保证该文件是除项目窗口以外其他唯一的窗口.<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;LocalLeader&gt;o 主要是为那些不能识别 &lt;C-Return&gt; 的终端而提供的.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;M-Return&gt;<br style="color: #0846ff;">
\v<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 同 &lt;Return&gt; 仅仅显示文件内容, 而光标依然停留在项目窗口中.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;2-LeftMouse&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; (Double-click) 双击鼠标左键, 如果当前光标下是一个已经展开的折叠则关闭<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 该折叠, 反之打开该折叠. 如果当前光标下为一个文件名, 则在|CTRL-W_p|(前<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 一窗口)或项目右侧新窗口中打开该文件. <br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;S-2-LeftMouse&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 同 &lt;S-Return&gt;.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;C-2-LeftMouse&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 同 &lt;C-Return&gt;.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;RightMouse&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 根据变量的值 g:proj_window_increment 增加项目窗口的宽度, 反复点击则为<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 在原宽度<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g:proj_window_width<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 和增加后的宽度<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; g:proj_window_width + g:proj_window_increment<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 之间切换.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 是否能够切换原窗口和宽窗口, 或手动改变窗口宽度均取决于全局变量<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; g:proj_flags 中的标志位 't' 是否设置. (参见|project-flags|).<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 注意在其他窗口中单击鼠标时右键并不能自动将光标定位到项目窗口.<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 在离开项目窗口后, 项目窗口宽度会变回到原宽度 g:proj_window_width.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;space&gt; 同 &lt;RightMouse&gt;<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;CTRL-Up&gt;<br style="color: #0846ff;">
\&lt;Up&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 移动文本或者折叠到当前光标的上一行. 在有的终端中可能无法识别此绑定而失效.<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &lt;LocalLeader&gt;&lt;Up&gt; 主要是为那些不能识别 &lt;C-Up&gt; 的终端而提供的.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;CTRL-Down&gt;<br style="color: #0846ff;">
\&lt;Down&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 移动文本或者折叠到当前光标的下一行. 在有的终端中可能无法识别此绑定而失效.<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &lt;LocalLeader&gt;&lt;Down&gt; 主要是为那些不能识别 &lt;C-Down&gt;.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\i&nbsp;&nbsp;&nbsp; 在状态栏中显示光标所在折叠完全解析和继承的参数.&nbsp; <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 这是专门为手动进入项目时进行相对路径和继承参数的调试而映射的.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\I&nbsp;&nbsp;&nbsp; 在状态栏显示光标下文件名的全名(含路径). 此功能是插件调用<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Project_GetFname(line('.'))函数来实现的.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\1 - \9<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 执行在 g:proj_run{x} 指定的命令, {x} 是执行命令入口的编号. <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 参考下文中的 g:proj_run1.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\f1-\f9<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 执行 g:proj_run_fold{x} 中指定的命令, {x} 执行命令入口的编号, 命令只针<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 对当前项目层的文件. 参考下文中的|project-settings|.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\F1-\F9<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 执行 g:proj_run_fold{x} 中指定的命令, {x} 是执行命令入口的编号. 对当前<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 项目层及其所有子项目的所有文件执行命令. 参考下文中的 |project-settings|<br style="color: #0846ff;">
<br style="color: #0846ff;">
\0&nbsp;&nbsp;&nbsp; 显示由 \1 到 \9 定义的命令.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\f0&nbsp;&nbsp;&nbsp; 显示由 \f1 到 \f9 和 \F1 到 \F9 所定义的命令. \F0 作用与此相同.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\l&nbsp;&nbsp;&nbsp; 加载当前项目中的所有文件到 Vim 中, 在加载过程中按任何键可以停止加载.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\L&nbsp;&nbsp;&nbsp; 加载当前项目及其子项目中的所有文件到 Vim 中. 请谨慎使用这个映射, 作者并<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 不建议在项目中含有成千上万的文件时使用该映射. (顺便提一句, 我的项目中有<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 5,300 多个文件!) 在加载过程中按任何键可以停止加载.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\w&nbsp;&nbsp;&nbsp; 删除当前项目层次中的所有文件. (并非真正删除文件, 只针对该项目组织而言.<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 如果文件被修改, 会先保存文件.) 擦除过程中按任意键可以停止此操作.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\W&nbsp;&nbsp;&nbsp; 删除当前项目层及其子层次中的所有文件. (并非真正删除文件, 只针对该项目组<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 织而言.&nbsp;&nbsp;&nbsp; 如果文件被修改, 会先保存文件.) 擦除过程中按任意键可以停止此操作.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\g&nbsp;&nbsp;&nbsp; 搜索当前项目层所有文件.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\G&nbsp;&nbsp;&nbsp; 搜索项目所有层所有文件.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\e&nbsp;&nbsp;&nbsp; 为先通过 &lt;Return&gt; 选择的项目文件设置环境变量. 例如在 \e 设定环境变量后, <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 无需打开项目中的任何文件便可用 :make 来进行编译.<br style="color: #0846ff;">
<br style="color: #0846ff;">
\E&nbsp;&nbsp;&nbsp; 使用 |file-explorer| 浏览光标处目录内的文件. 不支持 netrw 时的项目管理.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&lt;F12&gt;&nbsp;&nbsp;&nbsp; 当在变量 g:proj_flags (参考 |project-flags|)中使用了标志位 'g' 时, 该键<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用来切换打开和关闭项目窗口. 可以在 vimrc 中进行重新绑定. 例如将其映射到<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Leader&gt;P:<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nmap &lt;silent&gt; &lt;Leader&gt;P &lt;Plug&gt;ToggleProject<br style="color: #0846ff;">
<br style="color: #0846ff;">
注意由于使用 :help 时帮助窗口跟项目窗口有所冲突, 该插件通过重新映射 :help避免了<br style="color: #0846ff;">
这个问题(在使用时你可能无法感觉出来).<br style="color: #0846ff;">
<br style="color: #0846ff;">
==============================================================================<br style="color: #0846ff;">
ADDING MAPPINGS &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; *project-adding-mappings*<br style="color: #0846ff;">
添加映射<br style="color: #0846ff;">
<br style="color: #0846ff;">
也可单独在 $HOME/.vimproject_mappings 文件中设置自己需要的映射. 如果这个文件存<br style="color: #0846ff;">
在, 插件每次启动时候会执行(source)它. 下例中定义了统计项目中入口数量功能的映射<br style="color: #0846ff;">
当按下 \K (Kount, 这因为 C 与 K 谐音 :-):时候会显示统计结果 &gt;<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; function! s:Wc()<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let b:loadcount=0<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function! SpawnExec(infoline, fname, lineno, data)<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; let b:loadcount = b:loadcount + 1<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if getchar(0) != 0 | let b:stop_everything=1 | endif<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; endfunction<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call Project_ForEach(1, line('.'), "*SpawnExec", 0, '')<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delfunction SpawnExec<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echon b:loadcount." Files\r"<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unlet b:loadcount<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if exists("b:stop_everything")<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; unlet b:stop_everything<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; echon "Aborted.\r"<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; endif<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; endfunction<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; nnoremap &lt;buffer&gt; &lt;silent&gt; &lt;LocalLeader&gt;K :call &lt;SID&gt;Wc()&lt;CR&gt;<br style="color: #0846ff;">
<br style="color: #0846ff;">
下例在 $HOME/.vimproject_mappings 中实现了插件对perforce的整合:<br style="color: #0846ff;">
&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; function! s:DoP4(cmd)<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; let name=Project_GetFname(line('.'))<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; let dir=substitute(name, '\(.*\)/.*', '\1', 'g')<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; exec 'cd '.dir<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; exec "!".a:cmd.' '.Project_GetFname(line('.'))<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; cd -<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; endfunction<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; nmap &lt;buffer&gt; &lt;silent&gt; \pa :call &lt;SID&gt;DoP4("p4add")&lt;CR&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; nmap &lt;buffer&gt; &lt;silent&gt; \pe :call &lt;SID&gt;DoP4("p4edit")&lt;CR&gt;<br style="color: #0846ff;">
&lt;<br style="color: #0846ff;">
(注意我进入文件所在目录后才可以使用 $P4CONFIG 文件. 请参考关于 perforce 的文档.)<br style="color: #0846ff;">
<br style="color: #0846ff;">
这就建立了使用映射 \pe 来检查用于编辑的文件, 用 \pa 来将文件存储.<br style="color: #0846ff;">
<br style="color: #0846ff;">
<br style="color: #0846ff;">
下例中为 &lt;Return&gt; 在打开某种特定文件时映射到一个外部程序来. (该例中它调<br style="color: #0846ff;">
用 ee 来浏览jpg文件). 尽管看起来有些刻意, 但它还是有点用的.<br style="color: #0846ff;">
&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; let s:sid = substitute(maparg('&lt;Return&gt;', 'n'), '.*\(&lt;SNR&gt;.\{-}\)_.*', '\1', '')<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; function! s:LaunchOrWhat()<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; let fname=Project_GetFname(line('.'))<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if fname =~ '\.jpg$'<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exec 'silent! !ee "'.fname.'"&amp;'<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; call {s:sid}_DoFoldOrOpenEntry('', 'e')<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; endif<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; endfunction<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; nnoremap &lt;buffer&gt; &lt;silent&gt; &lt;Return&gt;&nbsp;&nbsp; \|:call &lt;SID&gt;LaunchOrWhat()&lt;CR&gt;<br style="color: #0846ff;">
&lt;<br style="color: #0846ff;">
该例中调用外部程序来查看后缀名为jpg的文件, 对其他文件则仍以原 &lt;Return&gt; 处理.<br style="color: #0846ff;">
<br style="color: #0846ff;">
==============================================================================<br style="color: #0846ff;">
SETTINGS&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *project-settings*<br style="color: #0846ff;">
<br style="color: #0846ff;">
在 vimrc 文件中设定下述变量后, Vim 会在加载插件前先使用这些属性从而不按照插<br style="color: #0846ff;">
件的默认属性进行加载.<br style="color: #0846ff;">
<br style="color: #0846ff;">
g:proj_window_width<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 插件项目窗口宽度.&nbsp;&nbsp;&nbsp; 默认值: 24<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 尽管插件不能完全成功地按照我预想的方式设定窗口的大小,但是这个变量在<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 设定窗口大小时还是会起到很大的作用.<br style="color: #0846ff;">
<br style="color: #0846ff;">
g:proj_window_increment<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 当按空格键 &lt;space&gt; 或者单击鼠标左键 &lt;LeftMouse &gt;时项目窗口宽度增加量<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 默认值: 100 (参见 |project-mappings|)<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *project-flags*<br style="color: #0846ff;">
g:proj_flags<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 默认值: "imst"<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 这些标志位可以用来控制插件的行为, 具体如下:<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 标志位&nbsp;&nbsp;&nbsp; 描述 ~<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; b&nbsp;&nbsp;&nbsp; 设置后将使用 |browse()| 通过浏览目录来为 \c 和 \C 设定目录.<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 默认关闭, 因为窗口浏览器本身不允许进行目录的选择.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; c&nbsp;&nbsp;&nbsp; 设置后, 在项目窗口中打开文件后会自动关闭项目窗口.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; F&nbsp;&nbsp;&nbsp; 显示浮动项目窗口. 关闭窗口的自动调整大小和窗口替换. <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; This allows placement between other windows that wish to share <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; similar placement at the side of the screen.&nbsp; <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 在使用外部窗口管理器的时候很有用.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; g&nbsp;&nbsp;&nbsp; 设置后会将切换打开和关闭项目窗口映射到 &lt;F12&gt; 上.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; i&nbsp;&nbsp;&nbsp; 设置后, 当选择打开一个文件时会在命令行显示文件名和当前工作路径.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; l&nbsp;&nbsp;&nbsp; 设置后, 项目插件在选择一个要打开的文件时,使用命令 |:lcd| 替换默<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 认的 |:cd| 命令去改变目录. 在有了下面的 L 标志位后, 此标志已经<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 用处不大.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; L&nbsp;&nbsp;&nbsp; 与标志位 l 很相似. 不管缓冲是否被使用, 它通过安装一个进入/离开<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 缓冲的自动命令|:autocommand| 来确保当前工作目录更改到 CD 参数<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 指定的目录.(|:lcd| 命令只能为窗口而不能为缓冲改变当前工作目录)<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; m&nbsp;&nbsp;&nbsp; 在常规模式下开启 |CTRL-W_o| 和 |CTRL-W_CTRL_O| 映射, 使得当前<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 缓冲区成为唯一可见的缓冲区, 但是项目窗口仍然可见.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp; 设置后将在项目窗口中显示行号.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; s&nbsp;&nbsp;&nbsp; 设置后将在项目窗口中使用语法高亮.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; S&nbsp;&nbsp;&nbsp; 设置后将在更新和创建项目时启用排序.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; t&nbsp;&nbsp;&nbsp; 设置后将在按空格 &lt;space&gt; 或鼠标右击 &lt;RightMouse&gt; 时候进行原窗口<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 和加宽窗口之间的切换. 参见 See the entry for&nbsp; in |project-mappings|.<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; T&nbsp;&nbsp;&nbsp; 设置后,&nbsp;&nbsp;&nbsp; 子项目的折叠在更新时会紧跟在当前折叠下方显示(而不是其底<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 部).<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; v&nbsp;&nbsp;&nbsp; 设置后将, 按 \G 搜索时用 :vimgrep 取代 :grep.<br style="color: #0846ff;">
<br style="color: #0846ff;">
g:proj_run1 ...&nbsp; g:proj_run9<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 包含一个作用于文件的 Vim 命令, 参考前文中关于 \1 to \9 的映射.<br style="color: #0846ff;">
&nbsp;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %f 替换文件的全路径和文件名<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %F 替换文件的全路径和文件名<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; is 替换文件的全路径和包含空格的文件<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %n 只替换文件名<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %N 只替换包含空格的文件名<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %h 替换项目主目录<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %H 替换包含空格的项目主目录<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %r 替换与 CD 目录相关联的路径<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %R 替换与包含空格的 CD 目录相关联的路径<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %d 替换 CD 目录.<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %D 替换包含空格的 CD 目录<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; %% 未使用<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 例如, 如果在 vimrc 中做了如下设置, 在当前光标下按下 \3 时将调<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 出 gvim : &gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;let g:proj_run3='silent !gvim %f'<br style="color: #0846ff;">
&lt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 其他的几个例子: &gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;let g:proj_run1='!p4 edit %f'<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;let g:proj_run2='!p4 add %f'<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;let g:proj_run4="echo 'Viewing %f'|sil !xterm -e less %f &amp;"<br style="color: #0846ff;">
&lt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 在 Windows 系统中应用单引号括住 %f, %h, %d 以避免 \ 引起的转义.<br style="color: #0846ff;">
<br style="color: #0846ff;">
g:proj_run_fold1 ...&nbsp; g:proj_run_fold9<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 包含一个作用于折叠内文件的 Vim 命令. 参考前文中关于 \f1 to \f9<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 和 \F1 to \F9 的映射部分.$HOME/.vimproject_mappings<br style="color: #0846ff;">
&nbsp;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; %f 替换文件名, %h 替换项目的主目录, %d 替换 CD 目录.<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 对应多个文件名有两种处理方式: <br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 第一种(默认的)处理方式使用 %f 替换所有的绝对文件名, 让命令只执<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 行一次;&nbsp;&nbsp;&nbsp; 第二种是让命令针对每个非绝对文件名执行一次, %f 每次只<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 替换一个文件名. 使用第二种方式时, 须在变量 g:proj_run_fold{x} <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 的开头加上一个通配符 '*' (通配符 '*' 在运行时将被自动去掉.)<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 例如, 注意以下两种方式的差异: &gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;let g:proj_run_fold3="*echo '%h/%f'"<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;let g:proj_run_fold4="echo '%f'"<br style="color: #0846ff;">
&lt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 注意在Windows系统中, 需要用 '' 将 %f, %h, %c 括起来, 否则路径中<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 使用的 \ 会出问题. 另一种办法是把它们放在 |escape()| 函数中.<br style="color: #0846ff;">
<br style="color: #0846ff;">
<br style="color: #0846ff;">
==============================================================================<br style="color: #0846ff;">
PROJECT EXAMPLE FILE&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; *project-example*<br style="color: #0846ff;">
<br style="color: #0846ff;">
例子: 项目文件(~/.vimprojects): &gt;<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp; 1&nbsp;&nbsp;&nbsp; My Project=~/c/project CD=. in=in.vim out=out.vim flags=r {<br style="color: #0846ff;">
&nbsp; 2&nbsp;&nbsp;&nbsp; &nbsp;Makefile<br style="color: #0846ff;">
&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in.vim<br style="color: #0846ff;">
&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.vim<br style="color: #0846ff;">
&nbsp; 5&nbsp;&nbsp;&nbsp; &nbsp;GUI Files=. filter="gui*.c gui*.h" {<br style="color: #0846ff;">
&nbsp; 6&nbsp;&nbsp;&nbsp; &nbsp; gui_window.c<br style="color: #0846ff;">
&nbsp; 7&nbsp;&nbsp;&nbsp; &nbsp; gui_dialog.c<br style="color: #0846ff;">
&nbsp; 8&nbsp;&nbsp;&nbsp; &nbsp; gui_list.c<br style="color: #0846ff;">
&nbsp; 9&nbsp;&nbsp;&nbsp; &nbsp; gui.h&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Header file<br style="color: #0846ff;">
&nbsp;10&nbsp;&nbsp;&nbsp; &nbsp;}<br style="color: #0846ff;">
&nbsp;11&nbsp;&nbsp;&nbsp; &nbsp;Database Files=. filter="data*.c data*.h" {<br style="color: #0846ff;">
&nbsp;12&nbsp;&nbsp;&nbsp; &nbsp; data_read.c<br style="color: #0846ff;">
&nbsp;13&nbsp;&nbsp;&nbsp; &nbsp; data_write.c<br style="color: #0846ff;">
&nbsp;14&nbsp;&nbsp;&nbsp; &nbsp; data.h<br style="color: #0846ff;">
&nbsp;15&nbsp;&nbsp;&nbsp; &nbsp;}<br style="color: #0846ff;">
&nbsp;16&nbsp;&nbsp;&nbsp; &nbsp;OS-Specific Files {<br style="color: #0846ff;">
&nbsp;17&nbsp;&nbsp;&nbsp; &nbsp; Win32=. filter="os_win32*.c os_win32*.h" {<br style="color: #0846ff;">
&nbsp;18&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; os_win32_gui.c<br style="color: #0846ff;">
&nbsp;19&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; os_win32_io.c<br style="color: #0846ff;">
&nbsp;20&nbsp;&nbsp;&nbsp; &nbsp; }<br style="color: #0846ff;">
&nbsp;21&nbsp;&nbsp;&nbsp; &nbsp; Unix=. filter="os_unix*.c os_unix*.h" {<br style="color: #0846ff;">
&nbsp;22&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; os_unix_gui.c<br style="color: #0846ff;">
&nbsp;23&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; os_unix_io.c<br style="color: #0846ff;">
&nbsp;24&nbsp;&nbsp;&nbsp; &nbsp; }<br style="color: #0846ff;">
&nbsp;25&nbsp;&nbsp;&nbsp; &nbsp;}<br style="color: #0846ff;">
&nbsp;26&nbsp;&nbsp;&nbsp; }<br style="color: #0846ff;">
<br style="color: #0846ff;">
(注意左侧的行号不是文件内容.)<br style="color: #0846ff;">
<br style="color: #0846ff;">
<br style="color: #0846ff;">
==============================================================================<br style="color: #0846ff;">
插件技巧 &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *project-tips*<br style="color: #0846ff;">
<br style="color: #0846ff;">
1.&nbsp; 先为项目创建一个入口: &gt;<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Label=~/wherever CD=. filter="*.c *.h" {<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; }<br style="color: #0846ff;">
&lt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 然后将光标定位在折叠上按 \r, 脚本会自动添加对应目录下所有 C 文件(本例中)<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 到项目之中. 这与 \c 是等效的, 只是没有对话框显示.<br style="color: #0846ff;">
<br style="color: #0846ff;">
2.&nbsp; 可以在项目列表里随时添加,删除或排序项目文件.<br style="color: #0846ff;">
<br style="color: #0846ff;">
3.&nbsp; 当项目窗口没有打开时, 输入 &gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; :Project<br style="color: #0846ff;">
&lt;&nbsp;&nbsp; 可以将其打开. (插件有自动记忆功能, 而无需输入具体的项目名称.) 如果在 <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; g:proj_flags 变量中设定了 'm' 标志位, 通过组合键 |CTRL-W_o| 可以重新打开<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 项目窗口. 毫无疑问, 这会关闭除当前窗口之外的其他所有打开的窗口.<br style="color: #0846ff;">
<br style="color: #0846ff;">
4.&nbsp; 往项目中添加新的文件. 例如添加 'more.c' 到项目中去, 只需在项目入口之中插<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 入文件名后按 &lt;Return&gt; 键即可.<br style="color: #0846ff;">
<br style="color: #0846ff;">
5.&nbsp; 当使用 |quickfix| 时候, 在文件名上按回车键 &lt;Return&gt; 并不会有效, 这样的话,<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 将无法更改目录, 运行脚本. 解决办法是在使用 |quickfix| 前用 \L 将所有文件<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 载入到项目中去. <br style="color: #0846ff;">
<br style="color: #0846ff;">
6.&nbsp; 当项目窗口因为或开或闭的折叠显得凌乱时, 使用 |zM| 可以关闭所有的展开折叠,<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 让项目窗口重新变得整洁如初.<br style="color: #0846ff;">
<br style="color: #0846ff;">
7.&nbsp; 对于高级用户, 可以尝试插件提供如下几个函数:<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Project_GetAllFnames() <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 返回一个折叠及其子项目(可选)下的所有文件名.&nbsp; <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Project_ForEach() <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 在为项目中的每个文件提供一个调用函数的接口.如何使用请参考上面的例子以<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 及源代码. <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; Project_GetFname(line_number) <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 在编写自己的映射时用来获取文件名.<br style="color: #0846ff;">
<br style="color: #0846ff;">
8.&nbsp; 将光标定位到项目插件窗口的键映射, 在 vimrc 文件中添加:<br style="color: #0846ff;">
&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nmap &lt;silent&gt; &lt;Leader&gt;P :Project&lt;CR&gt;<br style="color: #0846ff;">
&lt;<br style="color: #0846ff;">
9.&nbsp; 项目入口中使用符号"."会调出|file-explorer|插件. 为了防止在更新时候删除, <br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 在项目入口中加入:<br style="color: #0846ff;">
&gt;<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp;&nbsp; . # pragma keep<br style="color: #0846ff;">
&lt;<br style="color: #0846ff;">
==============================================================================<br style="color: #0846ff;">
致谢<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; 感谢下列朋友为我在此插件开发过程中提供一些补丁:<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Tomas Zellerin<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Lawrence Kesteloot<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Dave Eggum<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; A Harrison<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Thomas Link<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Richard Bair<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Eric Arnold<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Peter Jones<br style="color: #0846ff;">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Eric Van Dewoestine<br style="color: #0846ff;">
<br style="color: #0846ff;">
&nbsp;vim:ts=8 sw=8 noexpandtab tw=80 ft=help:<br>
<br><img src ="http://www.cppblog.com/DrMagic/aggbug/36964.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DrMagic/" target="_blank">Dr.Magic</a> 2007-11-19 19:11 <a href="http://www.cppblog.com/DrMagic/archive/2007/11/19/36964.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Test</title><link>http://www.cppblog.com/DrMagic/archive/2007/04/25/22815.html</link><dc:creator>Dr.Magic</dc:creator><author>Dr.Magic</author><pubDate>Wed, 25 Apr 2007 10:48:00 GMT</pubDate><guid>http://www.cppblog.com/DrMagic/archive/2007/04/25/22815.html</guid><wfw:comment>http://www.cppblog.com/DrMagic/comments/22815.html</wfw:comment><comments>http://www.cppblog.com/DrMagic/archive/2007/04/25/22815.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DrMagic/comments/commentRss/22815.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DrMagic/services/trackbacks/22815.html</trackback:ping><description><![CDATA[<a target=blank href=tencent://message/?uin=94030966&Site=drmagic.xicp.net&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:94030966:2 alt="点击这里给我发消息"></a><img src ="http://www.cppblog.com/DrMagic/aggbug/22815.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DrMagic/" target="_blank">Dr.Magic</a> 2007-04-25 18:48 <a href="http://www.cppblog.com/DrMagic/archive/2007/04/25/22815.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WTL White Paper</title><link>http://www.cppblog.com/DrMagic/archive/2006/03/27/4655.html</link><dc:creator>Dr.Magic</dc:creator><author>Dr.Magic</author><pubDate>Mon, 27 Mar 2006 07:47:00 GMT</pubDate><guid>http://www.cppblog.com/DrMagic/archive/2006/03/27/4655.html</guid><wfw:comment>http://www.cppblog.com/DrMagic/comments/4655.html</wfw:comment><comments>http://www.cppblog.com/DrMagic/archive/2006/03/27/4655.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/DrMagic/comments/commentRss/4655.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DrMagic/services/trackbacks/4655.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: WTL Makes UI Programming a Joy,  Part 1: The Basics																		 																										 																								The Windows Template Library (WTL) is availab...&nbsp;&nbsp;<a href='http://www.cppblog.com/DrMagic/archive/2006/03/27/4655.html'>阅读全文</a><img src ="http://www.cppblog.com/DrMagic/aggbug/4655.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DrMagic/" target="_blank">Dr.Magic</a> 2006-03-27 15:47 <a href="http://www.cppblog.com/DrMagic/archive/2006/03/27/4655.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Event Programming in C++ (Part I)</title><link>http://www.cppblog.com/DrMagic/archive/2006/03/16/4230.html</link><dc:creator>Dr.Magic</dc:creator><author>Dr.Magic</author><pubDate>Thu, 16 Mar 2006 03:08:00 GMT</pubDate><guid>http://www.cppblog.com/DrMagic/archive/2006/03/16/4230.html</guid><wfw:comment>http://www.cppblog.com/DrMagic/comments/4230.html</wfw:comment><comments>http://www.cppblog.com/DrMagic/archive/2006/03/16/4230.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/DrMagic/comments/commentRss/4230.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/DrMagic/services/trackbacks/4230.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Event Programming in C++ (Part I)Q:微软的.NET框架让我们能够为托管类定义事件并通过代理和”+=”操作符对其进行处理.那么在本地C++中有没有同样的方法呢，它看起来很有用.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;某些读者&nbsp;A:事实上确实有! Visual C++® .NET有种称为”统一事件模型”的东西能...&nbsp;&nbsp;<a href='http://www.cppblog.com/DrMagic/archive/2006/03/16/4230.html'>阅读全文</a><img src ="http://www.cppblog.com/DrMagic/aggbug/4230.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/DrMagic/" target="_blank">Dr.Magic</a> 2006-03-16 11:08 <a href="http://www.cppblog.com/DrMagic/archive/2006/03/16/4230.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>