﻿<?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++博客-&amp;豪-文章分类-Linux</title><link>http://www.cppblog.com/qywyh/category/7659.html</link><description>豪-&gt;blog</description><language>zh-cn</language><lastBuildDate>Thu, 31 Jul 2008 12:59:26 GMT</lastBuildDate><pubDate>Thu, 31 Jul 2008 12:59:26 GMT</pubDate><ttl>60</ttl><item><title>【转】top命令详解</title><link>http://www.cppblog.com/qywyh/articles/57646.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Thu, 31 Jul 2008 07:47:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/57646.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/57646.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/57646.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/57646.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/57646.html</trackback:ping><description><![CDATA[<table style="BORDER-COLLAPSE: collapse; WORD-WRAP: break-word" cellSpacing=0 cellPadding=0 width="100%" border=0>
    <tbody>
        <tr>
            <td align=middle height=25><font style="FONT-SIZE: 14pt" color=#02368d><strong>top命令详解</strong></font></strong></font><br></td>
        </tr>
        <tr>
            <td bgColor=#d2dee2 height=1></td>
        </tr>
        <tr>
            <td bgColor=#ffffff height=1></td>
        </tr>
        <tr>
            <td align=middle>
            <table style="BORDER-COLLAPSE: collapse; WORD-WRAP: break-word" cellSpacing=0 cellPadding=0 width="100%" border=0>
                <tbody>
                    <tr>
                        <td width="100%">
                        <div id=art style="MARGIN: 15px" width="100%">op命令是Linux下常用的性能分析工具，能够实时显示系统中各个进程的资源占用状况，类似于Windows的任务管理器。下面详细介绍它的使用方法。
                        <p>&#160;</p>
                        <table cellSpacing=1 cellPadding=1 width="100%" summary="" border=1>
                            <tbody>
                                <tr>
                                    <td>top - 01:06:48 up&nbsp; 1:22,&nbsp; 1 user,&nbsp; load average: 0.06, 0.60, 0.48<br>Tasks:&nbsp; 29 total,&nbsp;&nbsp; 1 running,&nbsp; 28 sleeping,&nbsp;&nbsp; 0 stopped,&nbsp;&nbsp; 0 zombie<br>Cpu(s):&nbsp; 0.3% us,&nbsp; 1.0% sy,&nbsp; 0.0% ni, 98.7% id,&nbsp; 0.0% wa,&nbsp; 0.0% hi,&nbsp; 0.0% si<br>Mem:&nbsp;&nbsp;&nbsp; 191272k total,&nbsp;&nbsp; 173656k used,&nbsp;&nbsp;&nbsp; 17616k free,&nbsp;&nbsp;&nbsp; 22052k buffers<br>Swap:&nbsp;&nbsp; 192772k total,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0k used,&nbsp;&nbsp; 192772k free,&nbsp;&nbsp; 123988k cached<br><br>&nbsp;&nbsp; PID USER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PR&nbsp; NI&nbsp; VIRT&nbsp; RES&nbsp; SHR S %CPU %MEM&nbsp;&nbsp;&nbsp; TIME+&nbsp; COMMAND<br>&nbsp; 1379 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp; 0&nbsp; 7976 2456 1980 S&nbsp; 0.7&nbsp; 1.3&nbsp;&nbsp; 0:11.03 sshd<br>14704 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp; 0&nbsp; 2128&nbsp; 980&nbsp; 796 R&nbsp; 0.7&nbsp; 0.5&nbsp;&nbsp; 0:02.72 top<br>&nbsp;&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp; 0&nbsp; 1992&nbsp; 632&nbsp; 544 S&nbsp; 0.0&nbsp; 0.3&nbsp;&nbsp; 0:00.90 init<br>&nbsp;&nbsp;&nbsp;&nbsp; 2 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 34&nbsp; 19&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0 S&nbsp; 0.0&nbsp; 0.0&nbsp;&nbsp; 0:00.00 ksoftirqd/0<br>&nbsp;&nbsp;&nbsp;&nbsp; 3 root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RT&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0 S&nbsp; 0.0&nbsp; 0.0&nbsp;&nbsp; 0:00.00 watchdog/0</td>
                                </tr>
                            </tbody>
                        </table>
                        <h4 id=content_1_1>统计信息区</h4>
                        <p>前五行是系统整体的统计信息。第一行是任务队列信息，同 uptime 命令的执行结果。其内容如下：</p>
                        <div class=ie5>
                        <table class=style_table cellSpacing=1 border=0>
                            <tbody>
                                <tr>
                                    <td class=style_td>01:06:48</td>
                                    <td class=style_td>当前时间</td>
                                </tr>
                                <tr>
                                    <td class=style_td>up 1:22</td>
                                    <td class=style_td>系统运行时间，格式为时:分</td>
                                </tr>
                                <tr>
                                    <td class=style_td>1 user</td>
                                    <td class=style_td>当前登录用户数</td>
                                </tr>
                                <tr>
                                    <td class=style_td>load average: 0.06, 0.60, 0.48</td>
                                    <td class=style_td>系统负载，即任务队列的平均长度。<br>三个数值分别为 1分钟、5分钟、15分钟前到现在的平均值。</td>
                                </tr>
                            </tbody>
                        </table>
                        </div>
                        <p>第二、三行为进程和CPU的信息。当有多个CPU时，这些内容可能会超过两行。内容如下：</p>
                        <div class=ie5>
                        <table class=style_table cellSpacing=1 border=0>
                            <tbody>
                                <tr>
                                    <td class=style_td>Tasks: 29 total</td>
                                    <td class=style_td>进程总数</td>
                                </tr>
                                <tr>
                                    <td class=style_td>1 running</td>
                                    <td class=style_td>正在运行的进程数</td>
                                </tr>
                                <tr>
                                    <td class=style_td>28 sleeping</td>
                                    <td class=style_td>睡眠的进程数</td>
                                </tr>
                                <tr>
                                    <td class=style_td>0 stopped</td>
                                    <td class=style_td>停止的进程数</td>
                                </tr>
                                <tr>
                                    <td class=style_td>0 zombie</td>
                                    <td class=style_td>僵尸进程数</td>
                                </tr>
                                <tr>
                                    <td class=style_td>Cpu(s): 0.3% us</td>
                                    <td class=style_td>用户空间占用CPU百分比</td>
                                </tr>
                                <tr>
                                    <td class=style_td>1.0% sy</td>
                                    <td class=style_td>内核空间占用CPU百分比</td>
                                </tr>
                                <tr>
                                    <td class=style_td>0.0% ni</td>
                                    <td class=style_td>用户进程空间内改变过优先级的进程占用CPU百分比</td>
                                </tr>
                                <tr>
                                    <td class=style_td>98.7% id</td>
                                    <td class=style_td>空闲CPU百分比</td>
                                </tr>
                                <tr>
                                    <td class=style_td>0.0% wa</td>
                                    <td class=style_td>等待输入输出的CPU时间百分比</td>
                                </tr>
                                <tr>
                                    <td class=style_td>0.0% hi</td>
                                    <td class=style_td>&nbsp;</td>
                                </tr>
                                <tr>
                                    <td class=style_td>0.0% si</td>
                                    <td class=style_td>&nbsp;</td>
                                </tr>
                            </tbody>
                        </table>
                        </div>
                        <p>最后两行为内存信息。内容如下：</p>
                        <div class=ie5>
                        <table class=style_table cellSpacing=1 border=0>
                            <tbody>
                                <tr>
                                    <td class=style_td>Mem: 191272k total</td>
                                    <td class=style_td>物理内存总量</td>
                                </tr>
                                <tr>
                                    <td class=style_td>173656k used</td>
                                    <td class=style_td>使用的物理内存总量</td>
                                </tr>
                                <tr>
                                    <td class=style_td>17616k free</td>
                                    <td class=style_td>空闲内存总量</td>
                                </tr>
                                <tr>
                                    <td class=style_td>22052k buffers</td>
                                    <td class=style_td>用作内核缓存的内存量</td>
                                </tr>
                                <tr>
                                    <td class=style_td>Swap: 192772k total</td>
                                    <td class=style_td>交换区总量</td>
                                </tr>
                                <tr>
                                    <td class=style_td>0k used</td>
                                    <td class=style_td>使用的交换区总量</td>
                                </tr>
                                <tr>
                                    <td class=style_td>192772k free</td>
                                    <td class=style_td>空闲交换区总量</td>
                                </tr>
                                <tr>
                                    <td class=style_td>123988k cached</td>
                                    <td class=style_td>缓冲的交换区总量。<br>内存中的内容被换出到交换区，而后又被换入到内存，但使用过的交换区尚未被覆盖，<br>该数值即为这些<strong>内容已存在于内存中</strong>的交换区的大小。<br>相应的内存再次被换出时可不必再对交换区写入。</td>
                                </tr>
                            </tbody>
                        </table>
                        </div>
                        <h4 id=content_1_2>进程信息区</h4>
                        <p>统计信息区域的下方显示了各个进程的详细信息。首先来认识一下各列的含义。</p>
                        <div class=ie5>
                        <table class=style_table cellSpacing=1 border=0>
                            <thead>
                                <tr>
                                    <td class=style_td>序号</td>
                                    <td class=style_td>列名</td>
                                    <td class=style_td>含义</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td class=style_td>a</td>
                                    <td class=style_td>PID</td>
                                    <td class=style_td>进程id</td>
                                </tr>
                                <tr>
                                    <td class=style_td>b</td>
                                    <td class=style_td>PPID</td>
                                    <td class=style_td>父进程id</td>
                                </tr>
                                <tr>
                                    <td class=style_td>c</td>
                                    <td class=style_td>RUSER</td>
                                    <td class=style_td>Real user name</td>
                                </tr>
                                <tr>
                                    <td class=style_td>d</td>
                                    <td class=style_td>UID</td>
                                    <td class=style_td>进程所有者的用户id</td>
                                </tr>
                                <tr>
                                    <td class=style_td>e</td>
                                    <td class=style_td>USER</td>
                                    <td class=style_td>进程所有者的用户名</td>
                                </tr>
                                <tr>
                                    <td class=style_td>f</td>
                                    <td class=style_td>GROUP</td>
                                    <td class=style_td>进程所有者的组名</td>
                                </tr>
                                <tr>
                                    <td class=style_td>g</td>
                                    <td class=style_td>TTY</td>
                                    <td class=style_td>启动进程的终端名。不是从终端启动的进程则显示为 ?</td>
                                </tr>
                                <tr>
                                    <td class=style_td>h</td>
                                    <td class=style_td>PR</td>
                                    <td class=style_td>优先级</td>
                                </tr>
                                <tr>
                                    <td class=style_td>i</td>
                                    <td class=style_td>NI</td>
                                    <td class=style_td>nice值。负值表示高优先级，正值表示低优先级</td>
                                </tr>
                                <tr>
                                    <td class=style_td>j</td>
                                    <td class=style_td>P</td>
                                    <td class=style_td>最后使用的CPU，仅在多CPU环境下有意义</td>
                                </tr>
                                <tr>
                                    <td class=style_td>k</td>
                                    <td class=style_td>%CPU</td>
                                    <td class=style_td>上次更新到现在的CPU时间占用百分比</td>
                                </tr>
                                <tr>
                                    <td class=style_td>l</td>
                                    <td class=style_td>TIME</td>
                                    <td class=style_td>进程使用的CPU时间总计，单位秒</td>
                                </tr>
                                <tr>
                                    <td class=style_td>m</td>
                                    <td class=style_td>TIME+</td>
                                    <td class=style_td>进程使用的CPU时间总计，单位1/100秒</td>
                                </tr>
                                <tr>
                                    <td class=style_td>n</td>
                                    <td class=style_td>%MEM</td>
                                    <td class=style_td>进程使用的<strong>物理内存</strong>百分比</td>
                                </tr>
                                <tr>
                                    <td class=style_td>o</td>
                                    <td class=style_td>VIRT</td>
                                    <td class=style_td>进程使用的虚拟内存总量，单位kb。VIRT=SWAP+RES</td>
                                </tr>
                                <tr>
                                    <td class=style_td>p</td>
                                    <td class=style_td>SWAP</td>
                                    <td class=style_td>进程使用的虚拟内存中，被换出的大小，单位kb。</td>
                                </tr>
                                <tr>
                                    <td class=style_td>q</td>
                                    <td class=style_td>RES</td>
                                    <td class=style_td>进程使用的、未被换出的物理内存大小，单位kb。RES=CODE+DATA</td>
                                </tr>
                                <tr>
                                    <td class=style_td>r</td>
                                    <td class=style_td>CODE</td>
                                    <td class=style_td>可执行代码占用的<strong>物理</strong>内存大小，单位kb</td>
                                </tr>
                                <tr>
                                    <td class=style_td>s</td>
                                    <td class=style_td>DATA</td>
                                    <td class=style_td>可执行代码以外的部分(数据段+栈)占用的<strong>物理</strong>内存大小，单位kb</td>
                                </tr>
                                <tr>
                                    <td class=style_td>t</td>
                                    <td class=style_td>SHR</td>
                                    <td class=style_td>共享内存大小，单位kb</td>
                                </tr>
                                <tr>
                                    <td class=style_td>u</td>
                                    <td class=style_td>nFLT</td>
                                    <td class=style_td>页面错误次数</td>
                                </tr>
                                <tr>
                                    <td class=style_td>v</td>
                                    <td class=style_td>nDRT</td>
                                    <td class=style_td>最后一次写入到现在，被修改过的页面数。</td>
                                </tr>
                                <tr>
                                    <td class=style_td>w</td>
                                    <td class=style_td>S</td>
                                    <td class=style_td>进程状态。<br><strong>D</strong>=不可中断的睡眠状态<br><strong>R</strong>=运行<br><strong>S</strong>=睡眠<br><strong>T</strong>=跟踪/停止<br><strong>Z</strong>=僵尸进程</td>
                                </tr>
                                <tr>
                                    <td class=style_td>x</td>
                                    <td class=style_td>COMMAND</td>
                                    <td class=style_td>命令名/命令行</td>
                                </tr>
                                <tr>
                                    <td class=style_td>y</td>
                                    <td class=style_td>WCHAN</td>
                                    <td class=style_td>若该进程在睡眠，则显示睡眠中的系统函数名</td>
                                </tr>
                                <tr>
                                    <td class=style_td>z</td>
                                    <td class=style_td>Flags</td>
                                    <td class=style_td>任务标志，参考 sched.h</td>
                                </tr>
                            </tbody>
                        </table>
                        </div>
                        <p>默认情况下仅显示比较重要的 PID、USER、PR、NI、VIRT、RES、SHR、S、%CPU、%MEM、TIME+、COMMAND 列。可以通过下面的快捷键来更改显示内容。</p>
                        <h3 id=content_1_3>更改显示内容</h3>
                        <p>通过 <strong>f </strong>键可以选择显示的内容。按 f 键之后会显示列的列表，按 a-z 即可显示或隐藏对应的列，最后按回车键确定。</p>
                        <p>按 <strong>o</strong> 键可以改变列的显示顺序。按小写的 a-z 可以将相应的列向右移动，而大写的 A-Z 可以将相应的列向左移动。最后按回车键确定。</p>
                        <p>按大写的 <strong>F</strong> 或 <strong>O</strong> 键，然后按 a-z 可以将进程按照相应的列进行排序。而大写的 <strong>R</strong> 键可以将当前的排序倒转。</p>
                        <p><font size=4><strong>命令使用</strong></font></p>
                        <p><span class=style6>1． 工具（命令）名称<br>top<br>2．工具（命令）作用<br>显示系统当前的进程和其他状况； top是一个动态显示过程,即可以通过用户按键来不断刷新当前状态.如果在前台执行该命令,它将独占前台,直到用户终止该程序为止. 比较准确的说,top命令提供了实时的对系统处理器的状态监视.它将显示系统中CPU最&#8220;敏感&#8221;的任务列表.该命令可以按CPU使用.内存使用和执行时间对任务进行排序；而且该命令的很多特性都可以通过交互式命令或者在个人定制文件中进行设定. <br>3．环境设置<br>在Linux下使用。<br>4．使用方法<br>4．1使用格式<br>top [-] [d] [p] [q] [c] [C] [S] [s]&nbsp; [n] <br>4．2参数说明<br>&nbsp;<font color=#ff0000>d </font>指定每两次屏幕信息刷新之间的时间间隔。当然用户可以使用s交互命令来改变之。<br><font color=#ff0000>&nbsp;p</font> 通过指定监控进程ID来仅仅监控某个进程的状态。<br>&nbsp;<font color=#ff0000>q</font>该选项将使top没有任何延迟的进行刷新。如果调用程序有超级用户权限，那么top将以尽可能高的优先级运行。<br><font color=#ff0000>&nbsp;S</font> 指定累计模式<br><font color=#ff0000>&nbsp;s</font> 使top命令在安全模式中运行。这将去除交互命令所带来的潜在危险。<br><font color=#ff0000>&nbsp;i</font>&nbsp; 使top不显示任何闲置或者僵死进程。<br><font color=#ff0000>&nbsp;c</font>&nbsp; 显示整个命令行而不只是显示命令名<br>4.3其他<br>　　下面介绍在top命令执行过程中可以使用的一些交互命令。从使用角度来看，熟练的掌握这些命令比掌握选项还重要一些。这些命令都是单字母的，如果在命令行选项中使用了s选项，则可能其中一些命令会被屏蔽掉。<br>　　<font color=#ff0000>Ctrl+L</font> 擦除并且重写屏幕。<br>　　<font color=#ff0000>h或者?</font> 显示帮助画面，给出一些简短的命令总结说明。<br>　　<font color=#ff0000>k</font> 终止一个进程。系统将提示用户输入需要终止的进程PID，以及需要发送给该进程什么样的信号。一般的终止进程可以使用15信号；如果不能正常结束那就使用信号9强制结束该进程。默认值是信号15。在安全模式中此命令被屏蔽。<br>　　<font color=#ff0000>i </font>忽略闲置和僵死进程。这是一个开关式命令。<br>　　<font color=#ff0000>q </font>退出程序。<br>　　<font color=#ff0000>r </font>重新安排一个进程的优先级别。系统提示用户输入需要改变的进程PID以及需要设置的进程优先级值。输入一个正值将使优先级降低，反之则可以使该进程拥有更高的优先权。默认值是10。<br>　　<font color=#ff0000>S </font>切换到累计模式。<br>　　<font color=#ff0000>s </font>改变两次刷新之间的延迟时间。系统将提示用户输入新的时间，单位为s。如果有小数，就换算成m s。输入0值则系统将不断刷新，默认值是5 s。需要注意的是如果设置太小的时间，很可能会引起不断刷新，从而根本来不及看清显示的情况，而且系统负载也会大大增加。<br>　　<font color=#ff0000>f或者F</font> 从当前显示中添加或者删除项目。<br>　　<font color=#ff0000>o或者O</font> 改变显示项目的顺序。<br>　　<font color=#ff0000>l </font>切换显示平均负载和启动时间信息。<br>　　<font color=#ff0000>m</font> 切换显示内存信息。<br>　　<font color=#ff0000>t </font>切换显示进程和CPU状态信息。<br>　　<font color=#ff0000>c </font>切换显示命令名称和完整命令行。<br>　<font color=#ff0000>　M</font> 根据驻留内存大小进行排序。<br>　　<font color=#ff0000>P </font>根据CPU使用百分比大小进行排序。<br>　　<font color=#ff0000>T</font> 根据时间/累计时间进行排序。<br><font color=#ff0000>&nbsp;&nbsp;&nbsp;&nbsp;W</font> 将当前设置写入~/.toprc文件中。这是写top配置文件的推荐方法。</span></p>
                        </div>
                        </td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.cppblog.com/qywyh/aggbug/57646.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2008-07-31 15:47 <a href="http://www.cppblog.com/qywyh/articles/57646.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】Vim设置</title><link>http://www.cppblog.com/qywyh/articles/57039.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Thu, 24 Jul 2008 04:16:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/57039.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/57039.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/57039.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/57039.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/57039.html</trackback:ping><description><![CDATA[<p class="g_w_100 g_t_wrap g_t_center g_t_bold g_t_24 g_c_pdin c07" id=blogtitle_fks_087065081083087064084081081095085086087065092086094>Vim设置（转）</p>
<div class=g_blog_list>
<div class="g_t_center g_c_pdin g_p_center c07 content" id=blogtext_fks_087065081083087064084081081095085086087065092086094 style="WIDTH: 760px"><span style="FONT-FAMILY: Courier New">" 设置字符编码。参考：http://www.rainux.org/blog/index.php/2005/10/20/106</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" encoding: Vim 内部使用的字符编码方式，包括 Vim 的 buffer (缓冲区)、菜单文</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 本、消息文本等。用户手册上建议只在 .vimrc 中改变它的值，事实上似乎也只有</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 在 .vimrc 中改变它的值才有意义。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 由于 Unicode 能够包含几乎所有的语言的字符，而且 Unicode 的 UTF-8 编码方式</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 又是非常具有性价比的编码方式 (空间消耗比 UCS-2 小)，因此建议 encoding 的</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 值设置为 utf-8。这么做的另一个理由是 encoding 设置为 utf-8 时，Vim 自动探</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 测文件的编码方式会更准确 (或许这个理由才是主要的)。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set encoding=utf-8</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" fileencodings: Vim 启动时会按照它所列出的字符编码方式逐一探测即将打开的文</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 件的字符编码方式，并且将 fileencoding 设置为最终探测到的字符编码方式。因</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 此最好将 Unicode 编码方式放到这个列表的最前面。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 拉丁语系编码方式 latin1 最好去掉。因为如果有 latin-1，在文件中有多种编码</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 方式的内容时 (比如，a 为 utf-8 编码的中文文本文件，b 为 cp936 编码的中文</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 文本文件，执行命令 cat b &gt;&gt; a 后的 a 文件)，最后 Vim 会将文件编码设为</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" latin-1，导致最终非英文内容显示完全乱码。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"set fileencodings=utf-8,chinese,latin-1</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set fileencodings=utf-8,chinese</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" fileencoding: Vim 中当前编辑的文件的字符编码方式，Vim 保存文件时也会将文</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 件保存为这种字符编码方式。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 如果打开的是已有的文件，则 Vim 会将 fileencoding 设置为上面探测到的字符编</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 码，此处的设置不再有效；如果是新文件，则此处的 fileencoding 生效。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">if has("win32")</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; " 我们在中文 Windows 里编辑的文件，为了兼顾与其他软件的兼容性，文件编码</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; " 还是设置为 GB2312/GBK 比较合适，因此 fileencoding 建议设置为 chinese</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; " (chinese 是个别名，在 Unix 里表示 gb2312，在 Windows 里表示 cp936，也</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; " 就是 GBK 的代码页)。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; set fileencoding=chinese</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">else</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; set fileencoding=utf-8</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">endif</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" termencoding: Vim 所工作的终端 (或者 Windows 的 Console 窗口) 的字符编码</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 方式。这个选项对 GUI 模式的 gVim 无效，而对 Console 模式的 Vim 而言就是</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" Windows 控制台的代码页 (对于 Windows 而言)，并且通常我们不需要改变它。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 下面这句只影响普通模式 (非图形界面) 下的 Vim。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">let &amp;termencoding=&amp;encoding</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 一般而言，在字符编码配置正确的情况下，是不会出现乱码问题的。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 万一不幸菜单乱码 (比如，locale 设置为 zh_CN.UTF-8 而 encoding 却设置为</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" cp936 时。当然，此时最好的方法还是将 encoding 设置为 utf-8) ，请取消下</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 面两行语句的注释。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"source $VIMRUNTIME/delmenu.vim</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"source $VIMRUNTIME/menu.vim</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 设置图形界面。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 字体部分，可参考《程序员最喜欢用的编程字体》一文：</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" http://www.2maomao.com/blog/best-programmer-fonts/</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">if has("gui_running")</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; if has("win32")</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设定 windows 下 gvim 启动时最大化</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; autocmd GUIEnter * simalt ~x</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设定 windows 下图形界面下的字体。该字体需要自己下载安装，下载地址：</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " http://ftp.gnome.org/pub/GNOME/sources/ttf-bitstream-vera/1.10/ttf-bitstream-vera-1.10.zip</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set guifont=Bitstream_Vera_Sans_Mono:h14:cANSI</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; else</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设定 linux 下图形界面下的字体，该字体 Fedora 7 自带</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set guifont=DejaVu\ LGC\ Sans\ Mono\ 14</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; endif</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">endif</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">colorscheme evening&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设定背景为夜间模式</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">filetype plugin on&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 自动识别文件类型，自动匹配对应的</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " &#8220;文件类型Plugin.vim&#8221;文件，使用缩进定义文件</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set ambiwidth=double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " ambiwidth 默认值为 single。在其值为 single 时，</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 若 encoding 为 utf-8，gvim 显示全角符号时就会</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 出问题，会当作半角显示。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set autochdir&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 自动切换当前目录为当前文件所在的目录</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set autoindent cindent cinoptions=g0</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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 语言风格的缩进模式，</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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 语言缩进风格</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set backspace=indent,eol,start</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 不设定的话在插入状态无法用退格键和 Delete</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 键删除回车符</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set backupcopy=yes&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设置备份时的行为为覆盖</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">if v:version &gt;= 700</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; set completeopt=menu,longest,preview</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 自动补全(ctrl-p)时的一些选项：</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 多于一项时显示菜单，最长选择，</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 显示当前选择的额外信息</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">endif</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set confirm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 用确认对话框（对于 gvim）或命令行选项（对于</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " vim）来代替有未保存内容时的警告信息</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set display=lastline&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 长行不能完全显示时显示当前屏幕能显示的部分。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 默认值为空，长行不能完全显示时显示 @。</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set expandtab&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 将 tab 键转换为空格</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set formatoptions=tcqro&nbsp;&nbsp;&nbsp;&nbsp; " 使得注释换行时自动加上前导的空格和星号</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set hidden&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 允许在有未保存的修改时切换缓冲区，</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 此时的修改由切换由 vim 负责保存</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set history=50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设置冒号命令和搜索命令的命令历史列表的长度为 50</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set hlsearch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 搜索时高亮显示被找到的文本</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set ignorecase smartcase&nbsp;&nbsp;&nbsp; " 搜索时忽略大小写，但在有一个或以上大写字母时</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 仍保持对大小写敏感</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set incsearch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 输入搜索内容时就显示搜索结果</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set mouse=a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设定在任何模式下鼠标都可用</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set nobackup&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 覆盖文件时不备份</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set nocompatible&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设定 gvim 运行在增强模式下</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set noignorecase&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 默认区分大小写</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set nolinebreak&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 在单词中间断行</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set number&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 显示行号</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set ruler&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 打开状态栏标尺</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"set scrolloff=5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设定光标离窗口上下边界 5 行时窗口自动滚动</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set shiftwidth=4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设定 &lt;&lt; 和 &gt;&gt; 命令移动时的宽度为 4</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set showcmd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 在状态栏显示目前所执行的指令，未完成的指令片段亦</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 会显示出来</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set softtabstop=4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 使得按退格键时可以一次删掉 4 个空格</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " （不足 4 个时删掉所有剩下的空格）</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set tabstop=4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设定 tab 长度为 4</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set whichwrap=b,s,&lt;,&gt;,[,]&nbsp;&nbsp; " 设定退格键、空格键以及左右方向键在行首行尾时的</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 行为，不影响 h 和 l 键</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set wrap&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 自动换行显示</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">syntax on&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 自动语法高亮</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 设置命令行和状态栏</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set cmdheight=1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 设定命令行的行数为 1</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set laststatus=2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " 显示状态栏 (默认值为 1, 无法显示状态栏)</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">set statusline=%F%m%r,%Y,%{&amp;fileformat}\ \ \ ASCII=\%b,HEX=\%B\ \ \ %l,%c%V\ %p%%\ \ \ [\ %L\ lines\ in\ all\ ]</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " 设置在状态行显示的信息如下：</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %F&nbsp;&nbsp;&nbsp; 当前文件名</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %m&nbsp;&nbsp;&nbsp; 当前文件修改状态</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %r&nbsp;&nbsp;&nbsp; 当前文件是否只读</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %Y&nbsp;&nbsp;&nbsp; 当前文件类型</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %{&amp;fileformat}</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; 当前文件编码</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %b&nbsp;&nbsp;&nbsp; 当前光标处字符的 ASCII 码值</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %B&nbsp;&nbsp;&nbsp; 当前光标处字符的十六进制值</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %l&nbsp;&nbsp;&nbsp; 当前光标行号</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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&nbsp;&nbsp;&nbsp; 当前光标列号</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %V&nbsp;&nbsp;&nbsp; 当前光标虚拟列号 (根据字符所占字节数计算)</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %p&nbsp;&nbsp;&nbsp; 当前行占总行数的百分比</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; 百分号</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&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; " %L&nbsp;&nbsp;&nbsp; 当前文件总行数</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 自动命令</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 读文件时自动设定当前目录为刚读入文件所在的目录</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">autocmd BufReadPost * cd %:p:h</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 自定义缩写</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">function! Eatchar(pat)</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; let s:c = nr2char(getchar())</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">&nbsp;&nbsp;&nbsp; return (s:c =~ a:pat) ? '' : s:c</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">endfunction</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" C 文件头注释</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; /**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /&lt;Esc&gt;75a*&lt;Esc&gt;o&lt;Esc&gt;0c$ * &lt;Esc&gt;yyADescription:&lt;Esc&gt;pmxpAAuthor&nbsp; : wplxb&lt;Esc&gt;pALanguage: C&lt;Esc&gt;pADate&nbsp;&nbsp;&nbsp; : &lt;C-R&gt;=strftime("%Y-%m-%d")&lt;CR&gt;&lt;Esc&gt;p$r/74i*&lt;Esc&gt;0vyo&lt;Esc&gt;`x$9pa</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" C 注释</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; ///&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* &lt;Esc&gt;mxa */&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; ***&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*&lt;Esc&gt;yyppr A/&lt;Esc&gt;k0r A &lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" C 预处理</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; #i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #include &lt;&lt;Esc&gt;mxa&gt;&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; #d&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #define</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" C 关键字</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; if(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (&lt;Esc&gt;mxa)&lt;CR&gt;{&lt;CR&gt;}&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; el{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else&lt;CR&gt;{&lt;Esc&gt;mxa&lt;CR&gt;}&lt;Esc&gt;`xa&lt;CR&gt;&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; ie(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (&lt;Esc&gt;mxa)&lt;CR&gt;{&lt;CR&gt;}&lt;CR&gt;else&lt;CR&gt;{&lt;CR&gt;}&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; fo(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (&lt;Esc&gt;mxa; ; )&lt;CR&gt;{&lt;CR&gt;}&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; fi(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; &lt;Esc&gt;mxa; ++i)&lt;CR&gt;{&lt;CR&gt;}&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; fi1(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i = 1; i &lt;= &lt;Esc&gt;mxa; ++i)&lt;CR&gt;{&lt;CR&gt;}&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; fj(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (j = 0; j &lt; &lt;Esc&gt;mxa; ++j)&lt;CR&gt;{&lt;CR&gt;}&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; fj1(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (j = 1; j &lt;= &lt;Esc&gt;mxa; ++j)&lt;CR&gt;{&lt;CR&gt;}&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; ma(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int main(int argc, char * argv[])&lt;CR&gt;{&lt;Esc&gt;mxa&lt;CR&gt;}&lt;Esc&gt;`xa&lt;CR&gt;&lt;CR&gt;return 0;&lt;Esc&gt;`xa&lt;CR&gt;&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; wh(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (&lt;Esc&gt;mxa)&lt;CR&gt;{&lt;CR&gt;}&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; sw(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (&lt;Esc&gt;mxa)&lt;CR&gt;{&lt;CR&gt;case &lt;Esc&gt;mya&lt;CR&gt;break;&lt;CR&gt;case &lt;Esc&gt;mza&lt;CR&gt;break;:&lt;Esc&gt;xa&lt;CR&gt;}&lt;Esc&gt;`yp`zp`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; sd(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (&lt;Esc&gt;mxa)&lt;CR&gt;{&lt;CR&gt;case &lt;Esc&gt;mya&lt;CR&gt;break;&lt;CR&gt;case &lt;Esc&gt;mza&lt;CR&gt;break;&lt;CR&gt;default:&lt;Esc&gt;vya&lt;CR&gt;}&lt;Esc&gt;`yp`zp`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" C 常用库函数</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; sc(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scanf("&lt;Esc&gt;mxa", );&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; fs(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fscanf(&lt;Esc&gt;mxa, "", );&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; ss(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sscanf(&lt;Esc&gt;mxa, "", );&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; pr(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("&lt;Esc&gt;mxa", );&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; prn(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("&lt;Esc&gt;mxa\n");&lt;Esc&gt;`x&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; fp(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(&lt;Esc&gt;mxa, "", );&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; sp(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sprintf(&lt;Esc&gt;mxa, "", );&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; cpy(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strcpy(&lt;Esc&gt;mxa, );&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; cat(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strcat(&lt;Esc&gt;mxa, );&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; len(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strlen(&lt;Esc&gt;mxa);&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; cmp(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strcmp(&lt;Esc&gt;mxa, );&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; qs(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qsort(&lt;Esc&gt;mxa, , , );&lt;Esc&gt;`xa&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">iab&nbsp;&nbsp;&nbsp;&nbsp; ---&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Esc&gt;75A-&lt;Esc&gt;a&lt;C-R&gt;=Eatchar('\s')&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">cab&nbsp;&nbsp;&nbsp;&nbsp; tn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tabnew</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">" 键映射</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">nmap&nbsp;&nbsp;&nbsp; &lt;F12&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :%s,\s\+$,,g&lt;CR&gt;</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"><span style="FONT-FAMILY: Courier New">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span><br style="FONT-FAMILY: Courier New"><br style="FONT-FAMILY: Courier New"></div>
</div>
<img src ="http://www.cppblog.com/qywyh/aggbug/57039.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2008-07-24 12:16 <a href="http://www.cppblog.com/qywyh/articles/57039.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】Linux系统配置VI或VIM的技巧</title><link>http://www.cppblog.com/qywyh/articles/57037.html</link><dc:creator>豪</dc:creator><author>豪</author><pubDate>Thu, 24 Jul 2008 04:05:00 GMT</pubDate><guid>http://www.cppblog.com/qywyh/articles/57037.html</guid><wfw:comment>http://www.cppblog.com/qywyh/comments/57037.html</wfw:comment><comments>http://www.cppblog.com/qywyh/articles/57037.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/qywyh/comments/commentRss/57037.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/qywyh/services/trackbacks/57037.html</trackback:ping><description><![CDATA[&nbsp;&nbsp; <br>首先 vim ~/.vimrc 打开编辑文件<br><br>[转]<br>&nbsp;&nbsp; 1、VI或VIM的配置文件的路径
<p>&nbsp;&nbsp;&nbsp; 发现/usr/share/vim/vimrc和/etc/vim/vimrc指向是同一个文件，即vimrc，为vi和vim的配置文件，修改这个文件即可。这个路径在不同的LINUX版本中可能会不同。</p>
<p>&nbsp;&nbsp;&nbsp; 2、配置颜色</p>
<p>&nbsp;&nbsp;&nbsp; 配轩VI和VIM的颜色显示，使它能够高亮度显示一些特别的单词，这对编写程序很有用。后来打开文件发现里面其实已经有一行了，只是用引号注释掉了，只需将syntax on 所在行前面的引号去掉即可。或者另外独立添加一行：syntax on 也行，另外编辑/etc/profile 增加一行alias vi="vim"就行了。</p>
<p>&nbsp;&nbsp;&nbsp; 3、设置鼠标</p>
<p>&nbsp;&nbsp;&nbsp; 使用VI编辑文本时，如果想修文件中改离光标较远的位置，这时候想用鼠标定位，可默认情况下，鼠标是不可用的。如果你想使用鼠标，只需另起一行，写上：set mouse=a 即可</p>
<p>&nbsp;&nbsp;&nbsp; 4、设置自动缩进</p>
<p>&nbsp;&nbsp;&nbsp; 默认情况下，VI和VIM都没有缩进的，每换一行，光标均定位在顶格，如果你想自动对齐，请将 set autoindent所在行前面的引号去掉，或者另外添加一行：set autoindent也可。这与配置颜色类似。这样的设置的结果是按回车后新行与上一行自动对齐。</p>
<p>&nbsp;&nbsp;&nbsp; 5、设置tab的缩进量</p>
<p>&nbsp;&nbsp;&nbsp; 如果用python编写程序，那么行缩进量是一个极其重要的概念，同一个块的缩进量必须相同。你可能喜欢在行前加空格来表示缩进，但每次必须敲多次空格键，如果你喜欢用按TAB键来表示缩进，你可能觉得写的文本或程序不太好看，因为默认情况下，VI和VIM的TAB缩进量比较大（至少六，七个字符）。设置TAB键缩进量的方法：set shiftwidth=3 你也可以选一 个你自己喜欢的缩进量，比如2，或4.</p>
<img src ="http://www.cppblog.com/qywyh/aggbug/57037.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/qywyh/" target="_blank">豪</a> 2008-07-24 12:05 <a href="http://www.cppblog.com/qywyh/articles/57037.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>