vim的配置文件在哪里
当我们使用Vim时, 你需要知道一系列的配置文件. 这些配置文件的位置依赖于Vim的安装位置和你所使用的操作系统.
通常, 有三个配置文件, 你是必须知道在哪里能找到的.
vimrc
这是Vim最主要的配置文件. 它有两个版本, 全局版本(global)和用户版本(personal)).
全局vimrc文件放在你安装Vim的目录中. 你可以打开vim, 在普通模式下输入下面的命令来找出这个目录的位置
:echo $VIM
结果应该是这样的:
Linux: /usr/share/vim/vimrc
Windows: c:\program files\vim\vimrc
用户版本的vimrc文件放在你的主目录下. 主目录的位置依赖于你的操作系统. Vim最初是为Unix及类Unix操作系统提供的, 所以用户版本的vimrc文件都是通过在文件名的最前面加一个点来设置成隐藏文件. 这是在类Unix上设置隐藏文件的方法, 但不适用于Microsoft Windows. 所以呢, vimrc文件与操作系统有关. 应该是这样的:
Linux: /home/kim/.vimrc
Windows: c:\documents and settings\kim\_vimrc
不管怎么改用户版的vimrc文件, 其中的设置内容都是覆盖在全局vimrc文件中设置的内容. 这就意味着你可以不需要去改变全局vimrc文件来进行配置Vim.
你可以在Vim的普通模式下输入下面的命令, 来找出Vim认为的你的系统的主目录的位置:
:echo $HOME
vimrc文件包含的是ex (vi的前身) 命令, 一条命令一行. 并且vimrc文件也是增加Vim配置信息的默认方式.
你的vimrc可以将其他的文件 (包含着配置信息) 作为外部资源. 在vimrc文件里, 你可用以source命令来实现:
source /path/to/external/file
这样可以使你的vimrc文件保持整洁, 并且你的设置会更加的结构 (更多的关于如何保持vimrc文件整洁的内容请参考附录B) .
===============================
<h1 style="margin: 17pt 0cm 7.8pt"><span style="font-family: 宋体">用</span><span><span style="font-family: Calibri">VIM</span></span><span style="font-family: 宋体">做</span><span><span style="font-family: Calibri"><a href="javascript:;" target="_self" onclick="javascript:tagshow(event, 'PHP');"><u><strong>PHP</strong></u></a></span></span><span style="font-family: 宋体">开发环境</span></h1><p style="margin: 0cm 0cm 7.8pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">作者:廖宇雷</span></span></p><span></span><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">虽然</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">本质上只是一个编辑器。但只要配合一些适当的插件,</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">也能变成一个全功能的</span><span><span style="font-family: Calibri">IDE</span></span><span style="font-family: 宋体">。笔者使用</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">已经有挺长一段时间了,经过反复的试验,配置了一个高效的</span><span><span style="font-family: Calibri">PHP</span></span><span style="font-family: 宋体">开发环境,实为居家旅行、谋财害命、杀人越货必备之良品。</span></span></p><span></span><h2 style="margin: 13pt 0cm 7.8pt"><span style="font-family: 宋体"><a href="javascript:;" target="_self" onclick="javascript:tagshow(event, '%B0%B2%D7%B0');"><u><strong>安装</strong></u></a></span><span><span style="font-family: Cambria">vim</span></span></h2><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">鉴于大多数读者都是使用</span><span><span style="font-family: Calibri"><a href="javascript:;" target="_self" onclick="javascript:tagshow(event, 'Windows');"><u><strong>Windows</strong></u></a></span></span><span style="font-family: 宋体">环境,所以本文就以</span><span><span style="font-family: Calibri">Windows</span></span><span style="font-family: 宋体">作为运行环境。不过由于</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">出色的跨平台特性,配置文件只需简单修改就可以在</span><span><span style="font-family: Calibri"><a href="javascript:;" target="_self" onclick="javascript:tagshow(event, 'Linux');"><u><strong>Linux</strong></u></a></span></span><span style="font-family: 宋体">版本的</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">中使用。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">目前</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">的最新版本是</span><span><span style="font-family: Calibri">7.2</span></span><span style="font-family: 宋体">,如果没有特别原因建议安装最新的版本。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://www.vim.org/download.php#pc"><span style="font-size: small; font-family: Calibri">http://www.vim.org/download.php#pc</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><a href="ftp://ftp.vim.org/pub/vim/pc/gvim72.exe"><span style="color: #800080; font-family: Calibri">ftp://ftp.vim.org/pub/vim/pc/gvim72.exe</span></a></span></span></p><span></span><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">安装时</span><span class="MsoIntenseEmphasis"><span style="font-family: 宋体"><strong><span style="color: #4f81bd">不要装到带有空格、中文的目录中</span></strong></span></span><span style="font-family: 宋体">,其他保持默认即可。笔者的安装目录是</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">c:\apps\office\vim</span></span></span><span style="font-family: 宋体">,后文也以此为准。为了叙述方便,笔者用</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">$VIM</span></span></span><span></span><span style="font-family: 宋体">来表示</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">的安装目录。例如您的</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">安装在</span><span><span style="font-family: Calibri">d:\vim\</span></span><span style="font-family: 宋体">中,那</span><span><span style="font-family: Calibri">$VIM</span></span><span style="font-family: 宋体">就代表</span><span><span style="font-family: Calibri">d:\vim\</span></span><span style="font-family: 宋体">。</span></span></p><span></span><h2 style="margin: 13pt 0cm 7.8pt"><span style="font-family: 宋体">开始配置</span><span><span style="font-family: Cambria">vim</span></span></h2><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">我们对</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">的配置分为几个步骤。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-size: large"><span style="font-family: 宋体">修改</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">后自动生效</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">打开</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">$VIM</span></span></span><span></span><span style="font-family: 宋体">目录,可以看到其中有一个</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">_vimrc</span></span></span><span></span><span style="font-family: 宋体">文件,用</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">打开此文件,删除所有内容后,在最后插入两行:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" autoload _vimrc</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">autocmd! bufwritepost _vimrc source %</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">上述命令让我们通过</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">编辑</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">文件并保存时,可以自动载入</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">文件,使得我们对</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">的定制可以立即生效(无需重启</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">)。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-size: large"><span style="font-family: 宋体">使</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">中文化</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">在</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">顶部增加下列文本:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" disable VI's compatible mode..</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set nocompatible</span></span></p><span></span><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" set encoding=utf-8</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set fileencodings=ucs-bom,utf-8,gbk,default,latin1</span></span></p><span></span><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" use chinese help</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set helplang=cn</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">上述<a href="javascript:;" target="_self" onclick="javascript:tagshow(event, '%B4%FA%C2%EB');"><u><strong>代码</strong></u></a>的作用是禁用</span><span><span style="font-family: Calibri">vi</span></span><span style="font-family: 宋体">兼容模式(原始的</span><span><span style="font-family: Calibri">vi</span></span><span style="font-family: 宋体">功能太少了,没必要考虑兼容)、按照</span><span><span style="font-family: Calibri">utf-8</span></span><span style="font-family: 宋体">、</span><span><span style="font-family: Calibri">gbk</span></span><span style="font-family: 宋体">的顺序来检测文件编码,并设置帮助为中文。不过设置</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">set helplang=cn</span></span></span><span></span><span style="font-family: 宋体">并不能马上看到中文帮助,我们还得下载中文帮助文件。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://vimcdoc.sourceforge.net/"><span style="font-size: small; font-family: Calibri">http://vimcdoc.sourceforge.net/</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><span style="font-family: Calibri">vimcdoc-1.6.0.tar.gz</span></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt; text-align: left" class="MsoNormal" align="left"><span style="font-size: small"><span style="font-family: 宋体">得到中文帮助文件压缩包后,将压缩包中</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">doc</span></span></span><span></span><span style="font-family: 宋体">子目录的所有文件复制到</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">$VIM\vimfiles\doc</span></span></span><span></span><span style="font-family: 宋体">目录中。此时再输入</span><strong><span><span style="color: #ff0000">:help</span></span></strong><span></span><span style="font-family: 宋体">命令就可以看到中文帮助了。</span></span></p><p style="margin: 12pt 0cm 7.8pt; text-align: center" class="MsoNormal" align="center"><span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">中文帮助还是</span><span><span style="font-family: Calibri">7.1</span></span><span style="font-family: 宋体">版的,不过不影响我们使用。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-family: 宋体"><span style="font-size: large">设置字体</span></span></h3><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">选择</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">菜单的“编辑”</span><span><span style="font-family: Calibri">-></span></span><span style="font-family: 宋体">“选择字体”,就可以为</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">指定喜欢的显示字体了。笔者使用的是</span><span style="font-family: Calibri"><span>Consolas</span></span><span style="font-family: 宋体">字体,大小设置为</span><span><span style="font-family: Calibri">9pt</span></span><span style="font-family: 宋体">。这个设置显示代码非常漂亮,不过中文就有点变形了。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">设置好后,输入命令</span><strong><span><span style="color: #ff0000">:set guifont</span></span></strong><span></span><span style="font-family: 宋体">可以查看到当前的字体设置,将该设置写入</span><span style="font-family: Calibri"><span>_vimrc</span></span><span style="font-family: 宋体">文件。</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">"set gui options</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">if has("gui_running")</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small"><span style="color: #244061"><span style="font-family: Consolas"><span> </span>set guifont=Consolas:h9</span></span></span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">endif</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">上述代码中的</span><span><span style="font-family: Calibri">if … endif</span></span><span style="font-family: 宋体">是一个条件判断结构。指示只有当我们使用图形界面版的</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">时才设置字体。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-size: large"><span style="font-family: 宋体">为编辑</span><span><span style="font-family: Calibri">PHP</span></span><span style="font-family: 宋体">代码进行基本设置</span></span></h3><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">现在用</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">打开</span><span><span style="font-family: Calibri">.php</span></span><span style="font-family: 宋体">文件看上去是很难看的,别说代码高亮,连行号都没有显示。所以还要给</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">添加以下内容:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Enable syntax highlight</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">syntax enable</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Show line number</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set nu</span></span></p><span></span><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" show matching bracets</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set showmatch</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Basic editing options</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set expandtab</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set shiftwidth=2</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">au FileType html,python,vim,javascript setl shiftwidth=2</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">au FileType html,python,vim,javascript setl tabstop=2</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">au FileType java,php setl shiftwidth=4</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">au FileType java,php setl tabstop=4</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set smarttab</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set lbr</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set tw=0</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">"Auto indent</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set ai</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Smart indet</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set si</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" C-style indeting</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set cindent</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Wrap lines</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set wrap</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">上述设置启用了格式化高亮、行号显示,以及括号匹配、自动缩进等编辑功能,对于大多数情况都可以获得理想的编辑体验。不过此时对</span><span><span style="font-family: Calibri">.php</span></span><span style="font-family: 宋体">文件的支持还不完善,需要下载专门的</span><span><span style="font-family: Calibri">php</span></span><span style="font-family: 宋体">插件。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://www.vim.org/scripts/script.php?script_id=1571"><span style="font-size: small; font-family: Calibri">http://www.vim.org/scripts/script.php?script_id=1571</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><span style="font-family: Calibri">php.tar.gz</span></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">将其中的</span><span><span style="font-family: Calibri">php.vim</span></span><span style="font-family: 宋体">复制到</span><span><span style="font-family: Calibri">$VIM\vimfiles\syntax</span></span><span style="font-family: 宋体">目录中即可。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-family: 宋体"><span style="font-size: large">设置喜欢的配色方案</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">默认的配色方案相信没几个人会喜欢,可以通过下面的网址查看配色方案并下载(有几百个哦)。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">下载网址:</span><span><a href="http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-c.html"><span style="font-family: Calibri">http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-c.html</span></a></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">这个网址列出了</span><span><span style="font-family: Calibri">300</span></span><span style="font-family: 宋体">多个配色方案以及实际的显示效果,点击方案名称即可下载到一个</span><span><span style="font-family: Calibri">.vim</span></span><span style="font-family: 宋体">文件。将该文件放入</span><span><span style="font-family: Calibri">$VIM\vimfiles\colors</span></span><span style="font-family: 宋体">目录,然后在</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">中添加:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" set color schema</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">colorscheme oceandeep</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">这两行代码需要加到</span><span style="font-family: Calibri"><span>if has("gui_running") … endif</span></span><span style="font-family: 宋体">代码块中,例如:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">if has("gui_running")</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small"><span style="color: #244061"><span style="font-family: Consolas"><span> </span>set guifont=Consolas:h9</span></span></span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small"><span style="color: #244061"><span style="font-family: Consolas"><span> </span>" set color schema</span></span></span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small"><span style="color: #244061"><span style="font-family: Consolas"><span> </span>colorscheme oceandeep</span></span></span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">endif</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">设置后显示效果就漂亮多了</span><span><span style="font-family: Calibri">:-)</span></span></span><span><span style="font-size: small; font-family: Calibri">­</span></span></p><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-family: 宋体"><span style="font-size: large">更多有用的编辑设置</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt; text-align: left" class="MsoNormal" align="left"><span style="font-size: small"><span style="font-family: 宋体">虽然不是专门针对编辑</span><span><span style="font-family: Calibri">.php</span></span><span style="font-family: 宋体">文件的设置,但这些选项可以让</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">更好用,所以建议加上:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Sets how many lines of history VIM har to remember</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set history=400</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Set to auto read when a file is changed from the outside</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set autoread</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Have the mouse enabled all the time:</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set mouse=a</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Do not redraw, when running macros.. lazyredraw</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set lz</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" set 7 lines to the curors - when moving vertical..</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set so=7</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" The commandbar is 2 high</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set cmdheight=2</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Change buffer - without saving</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set hid</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Ignore case when searching</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" set ignorecase</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set incsearch</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Set magic on</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set magic</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" No sound on errors.</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set noerrorbells</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set novisualbell</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set t_vb=</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" How many tenths of a second to blink</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set mat=4</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Highlight search things</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set hlsearch</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Turn backup off</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set nobackup</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set nowb</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set noswapfile</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" smart backspace</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set backspace=start,indent,eol</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" switch buffers with Tab</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">map <C-Tab> :bn<CR></span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">map <S-Tab> :bp<CR></span></span></p></div><span><span style="font-size: small; font-family: Calibri"> </span></span> <p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt; text-align: left" class="MsoNormal" align="left"><span style="font-size: small"><span style="font-family: 宋体">经过一番改造,我们的</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">已经可以很顺手的编辑</span><span><span style="font-family: Calibri">.php</span></span><span style="font-family: 宋体">文件了。不过要打造</span><span><span style="font-family: Calibri">php</span></span><span style="font-family: 宋体">开发环境还有很多<a href="javascript:;" target="_self" onclick="javascript:tagshow(event, '%B9%A4%D7%F7');"><u><strong>工作</strong></u></a>要做呢。</span></span></p><span></span><h2 style="margin: 13pt 0cm 7.8pt"><span style="font-family: 宋体">打造</span><span><span style="font-family: Cambria">PHP IDE</span></span></h2><p style="margin: 0cm 0cm 7.8pt" class="MsoNormal"></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span><span style="font-family: Calibri">IDE</span></span><span style="font-family: 宋体">左侧是目录导航,中间是编辑区域,而右侧则是<a href="javascript:;" target="_self" onclick="javascript:tagshow(event, '%B7%BD%B7%A8');"><u><strong>方法</strong></u></a>列表,用于在已经打开的文件中快速跳转。在编辑区域按下</span><span style="font-family: Calibri"><span>CTRL+X</span></span><span style="font-family: 宋体">键,还会显示已打开文件的列表。</span></span></p><p style="margin: 0cm 0cm 7.8pt" class="MsoNormal"></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">其他诸如自动补全、代码模板等功能,都应有尽有。看过了漂亮的截图,我们就来一步步打造</span><span><span style="font-family: Calibri">PHP IDE</span></span><span style="font-family: 宋体">吧。</span></span></p><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-size: large"><span style="font-family: 宋体">用</span><span><span style="font-family: Calibri">NERDTree</span></span><span style="font-family: 宋体">实现目录导航</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">在进行</span><span><span style="font-family: Calibri">PHP</span></span><span style="font-family: 宋体">应用开发时,同时编辑多个文件是很正常的事情。所以必须有一个方便的目录导航工具,以便在目录结构间快速切换,找到需要编辑的文件。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">中提供该类功能的插件很多,比较知名的有</span><span><span style="font-family: Calibri">project</span></span><span style="font-family: 宋体">、</span><span><span style="font-family: Calibri">winmanager</span></span><span style="font-family: 宋体">等。但笔者个人认为最好用的还是</span><span><span style="font-family: Calibri">The NERD Tree</span></span><span style="font-family: 宋体">这个插件。</span><span><span style="font-family: Calibri">NERDTree</span></span><span style="font-family: 宋体">不但可以显示完整的目录树结构,还可以将任何一个目录设置为根目录。并且提供了目录导航的书签功能,可谓非常方便。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://www.vim.org/scripts/script.php?script_id=1658"><span style="font-size: small; font-family: Calibri">http://www.vim.org/scripts/script.php?script_id=1658</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><span style="font-family: Calibri">NERD_tree.zip</span></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">解压缩时,要把压缩包中的目录结构完整的解压缩到</span><span><span style="font-family: Calibri">$VIM\vimfiles</span></span><span style="font-family: 宋体">目录中。完成后,应该分别找到</span><span style="font-family: Calibri"><span>$VIM\vimfiles\doc\NERD_tree.txt</span></span><span style="font-family: 宋体">文件和</span><span><span style="font-family: Calibri">$VIM\vimfiles\plugin\NERD_tree.vim</span></span><span style="font-family: 宋体">文件。然后在</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">中输入命令</span><strong><span><span style="color: #ff0000">:helptags $VIM\vimfiles\doc</span></span></strong><span style="font-family: 宋体">,将</span><span><span style="font-family: Calibri">NERDTree</span></span><span style="font-family: 宋体">的帮助文档添加到</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">中。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">最后在</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">添加如下内容:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" NERDTree</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">map <F10> :NERDTreeToggle<CR></span></span></p></div><span style="font-size: small"><span style="font-family: 宋体">重启</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">后,按下</span><span><span style="font-family: Calibri">F10</span></span><span style="font-family: 宋体">键,就可以在左侧看到一个目录树了。在目录树窗口中按下</span><span><span style="font-family: Calibri">?</span></span><span style="font-family: 宋体">键可以查看详细的帮助信息。</span></span><span><span style="font-size: small; font-family: Calibri"> </span></span> <p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">最常用的操作键有:</span></span></p><p></p><table border="1" cellspacing="1" cellpadding="1" width="531" style="width: 531px; height: 179px"><tbody><tr><td> <strong><span style="color: #365f91; font-family: 宋体">按键</span><span style="color: #365f91"></span></strong></td><td> <strong><span style="color: #365f91; font-family: 宋体">作用</span><span style="color: #365f91"></span></strong></td></tr><tr><td> <strong><span style="color: #365f91"><span style="font-family: Calibri">C</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">(大写</span><span style="color: #365f91"><span style="font-family: Calibri">C</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">键)</span><span style="color: #365f91"></span></strong></td><td> <span style="color: #365f91; font-family: 宋体">将光标所在目录设置为根目录</span><span style="color: #365f91"></span></td></tr><tr><td> <strong><span style="color: #365f91"><span style="font-family: Calibri">u</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">(小写</span><span style="color: #365f91"><span style="font-family: Calibri">u</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">键)</span><span style="color: #365f91"></span></strong></td><td> <span style="color: #365f91; font-family: 宋体">转到上一级目录</span><span style="color: #365f91"></span></td></tr><tr><td> <strong><span style="color: #365f91"><span style="font-family: Calibri">o</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">(小写</span><span style="color: #365f91"><span style="font-family: Calibri">o</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">键,不是“零”)</span><span style="color: #365f91"></span></strong></td><td> <span style="color: #365f91; font-family: 宋体">展开(或折叠)光标所在目录的子目录。如果光标所在位置是一个文件,则在编辑窗口中打开该文件</span><span style="color: #365f91"></span></td></tr></tbody></table><span></span><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">此外在目录树窗口中输入目录</span><span style="color: #ff0000"><strong><span>:Bookmark</span></strong><strong><span style="font-family: 宋体">收藏名</span></strong></span><span style="font-family: 宋体">还可以将光标所在目录添加到收藏夹中。下次使用</span><span style="color: #ff0000"><strong><span>:BookmarkToRoot</span></strong><strong><span style="font-family: 宋体">收藏名</span></strong></span><span style="font-family: 宋体">可以直接转到该目录,并且以该目录作为根目录。更多命令可以参考</span><span><span style="font-family: Calibri">NERDTree</span></span><span style="font-family: 宋体">的帮助文档。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-size: large"><span style="font-family: 宋体">用</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">实现代码导航</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">解决了目录和文件导航问题,我们还要为代码之间的跳转提供辅助手段,</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">就是这样一个插件。</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">可以列出已打开文件中定义的类、函数、常量,甚至变量。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://www.vim.org/scripts/script.php?script_id=273"><span style="font-size: small; font-family: Calibri">http://www.vim.org/scripts/script.php?script_id=273</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><span style="font-family: Calibri">taglist_45.zip</span></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">压缩包需要完整解压缩到</span><span><span style="font-family: Calibri">$VIM\vimfiles</span></span><span style="font-family: 宋体">目录,并且用</span><strong><span><span style="color: #ff0000">:helptags $VIM\vimfiles\doc</span></span></strong><span></span><span style="font-family: 宋体">命令索引</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">插件的帮助文档。</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">插件需要依赖</span><span><span style="font-family: Calibri">ctags</span></span><span style="font-family: 宋体">程序才能工作。目前常用的</span><span><span style="font-family: Calibri">ctags</span></span><span style="font-family: 宋体">版本是</span><span><span style="font-family: Calibri">Exuberant Ctags</span></span><span style="font-family: 宋体">。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://ctags.sourceforge.net/"><span style="font-size: small; font-family: Calibri">http://ctags.sourceforge.net/</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><span style="font-family: Calibri">ec57w32.zip</span></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">只需要把压缩包中的</span><span><span style="font-family: Calibri">ctags.exe</span></span><span style="font-family: 宋体">复制到</span><span><span style="font-family: Calibri">$VIM\vim72</span></span><span style="font-family: 宋体">目录中即可。</span><span><span style="font-family: Calibri">ctags.exe</span></span><span style="font-family: 宋体">应该和</span><span><span style="font-family: Calibri">gvim.exe</span></span><span style="font-family: 宋体">在一个目录。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">最后在</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">添加下列内容,设置好</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">插件:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" => Plugin configuration</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" taglist</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Auto_Highlight_Tag = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Auto_Open = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Auto_Update = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Close_On_Select = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Compact_Format = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Display_Prototype = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Display_Tag_Scope = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Enable_Fold_Column = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Exit_OnlyWindow = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_File_Fold_Auto_Close = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_GainFocus_On_ToggleOpen = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Hightlight_Tag_On_BufEnter = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Inc_Winwidth = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Max_Submenu_Items = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Max_Tag_Length = 30</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Process_File_Always = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Show_Menu = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Show_One_File = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Sort_Type = "order"</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Use_Horiz_Window = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Use_Right_Window = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_WinWidth = 40</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let tlist_php_settings = 'php;c:class;i:interfaces;d:constant;f:function'</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">这里的设置是笔者个人习惯的设置,大家在熟悉</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">的具体设置之前可以先尝试一下。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">设置完成后,在编辑</span><span><span style="font-family: Calibri">.php</span></span></span></p>
当我们使用Vim时, 你需要知道一系列的配置文件. 这些配置文件的位置依赖于Vim的安装位置和你所使用的操作系统.
通常, 有三个配置文件, 你是必须知道在哪里能找到的.
vimrc
这是Vim最主要的配置文件. 它有两个版本, 全局版本(global)和用户版本(personal)).
全局vimrc文件放在你安装Vim的目录中. 你可以打开vim, 在普通模式下输入下面的命令来找出这个目录的位置
:echo $VIM
结果应该是这样的:
Linux: /usr/share/vim/vimrc
Windows: c:\program files\vim\vimrc
用户版本的vimrc文件放在你的主目录下. 主目录的位置依赖于你的操作系统. Vim最初是为Unix及类Unix操作系统提供的, 所以用户版本的vimrc文件都是通过在文件名的最前面加一个点来设置成隐藏文件. 这是在类Unix上设置隐藏文件的方法, 但不适用于Microsoft Windows. 所以呢, vimrc文件与操作系统有关. 应该是这样的:
Linux: /home/kim/.vimrc
Windows: c:\documents and settings\kim\_vimrc
不管怎么改用户版的vimrc文件, 其中的设置内容都是覆盖在全局vimrc文件中设置的内容. 这就意味着你可以不需要去改变全局vimrc文件来进行配置Vim.
你可以在Vim的普通模式下输入下面的命令, 来找出Vim认为的你的系统的主目录的位置:
:echo $HOME
vimrc文件包含的是ex (vi的前身) 命令, 一条命令一行. 并且vimrc文件也是增加Vim配置信息的默认方式.
你的vimrc可以将其他的文件 (包含着配置信息) 作为外部资源. 在vimrc文件里, 你可用以source命令来实现:
source /path/to/external/file
这样可以使你的vimrc文件保持整洁, 并且你的设置会更加的结构 (更多的关于如何保持vimrc文件整洁的内容请参考附录B) .
===============================
<h1 style="margin: 17pt 0cm 7.8pt"><span style="font-family: 宋体">用</span><span><span style="font-family: Calibri">VIM</span></span><span style="font-family: 宋体">做</span><span><span style="font-family: Calibri"><a href="javascript:;" target="_self" onclick="javascript:tagshow(event, 'PHP');"><u><strong>PHP</strong></u></a></span></span><span style="font-family: 宋体">开发环境</span></h1><p style="margin: 0cm 0cm 7.8pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">作者:廖宇雷</span></span></p><span></span><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">虽然</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">本质上只是一个编辑器。但只要配合一些适当的插件,</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">也能变成一个全功能的</span><span><span style="font-family: Calibri">IDE</span></span><span style="font-family: 宋体">。笔者使用</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">已经有挺长一段时间了,经过反复的试验,配置了一个高效的</span><span><span style="font-family: Calibri">PHP</span></span><span style="font-family: 宋体">开发环境,实为居家旅行、谋财害命、杀人越货必备之良品。</span></span></p><span></span><h2 style="margin: 13pt 0cm 7.8pt"><span style="font-family: 宋体"><a href="javascript:;" target="_self" onclick="javascript:tagshow(event, '%B0%B2%D7%B0');"><u><strong>安装</strong></u></a></span><span><span style="font-family: Cambria">vim</span></span></h2><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">鉴于大多数读者都是使用</span><span><span style="font-family: Calibri"><a href="javascript:;" target="_self" onclick="javascript:tagshow(event, 'Windows');"><u><strong>Windows</strong></u></a></span></span><span style="font-family: 宋体">环境,所以本文就以</span><span><span style="font-family: Calibri">Windows</span></span><span style="font-family: 宋体">作为运行环境。不过由于</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">出色的跨平台特性,配置文件只需简单修改就可以在</span><span><span style="font-family: Calibri"><a href="javascript:;" target="_self" onclick="javascript:tagshow(event, 'Linux');"><u><strong>Linux</strong></u></a></span></span><span style="font-family: 宋体">版本的</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">中使用。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">目前</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">的最新版本是</span><span><span style="font-family: Calibri">7.2</span></span><span style="font-family: 宋体">,如果没有特别原因建议安装最新的版本。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://www.vim.org/download.php#pc"><span style="font-size: small; font-family: Calibri">http://www.vim.org/download.php#pc</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><a href="ftp://ftp.vim.org/pub/vim/pc/gvim72.exe"><span style="color: #800080; font-family: Calibri">ftp://ftp.vim.org/pub/vim/pc/gvim72.exe</span></a></span></span></p><span></span><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">安装时</span><span class="MsoIntenseEmphasis"><span style="font-family: 宋体"><strong><span style="color: #4f81bd">不要装到带有空格、中文的目录中</span></strong></span></span><span style="font-family: 宋体">,其他保持默认即可。笔者的安装目录是</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">c:\apps\office\vim</span></span></span><span style="font-family: 宋体">,后文也以此为准。为了叙述方便,笔者用</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">$VIM</span></span></span><span></span><span style="font-family: 宋体">来表示</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">的安装目录。例如您的</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">安装在</span><span><span style="font-family: Calibri">d:\vim\</span></span><span style="font-family: 宋体">中,那</span><span><span style="font-family: Calibri">$VIM</span></span><span style="font-family: 宋体">就代表</span><span><span style="font-family: Calibri">d:\vim\</span></span><span style="font-family: 宋体">。</span></span></p><span></span><h2 style="margin: 13pt 0cm 7.8pt"><span style="font-family: 宋体">开始配置</span><span><span style="font-family: Cambria">vim</span></span></h2><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">我们对</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">的配置分为几个步骤。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-size: large"><span style="font-family: 宋体">修改</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">后自动生效</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">打开</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">$VIM</span></span></span><span></span><span style="font-family: 宋体">目录,可以看到其中有一个</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">_vimrc</span></span></span><span></span><span style="font-family: 宋体">文件,用</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">打开此文件,删除所有内容后,在最后插入两行:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" autoload _vimrc</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">autocmd! bufwritepost _vimrc source %</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">上述命令让我们通过</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">编辑</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">文件并保存时,可以自动载入</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">文件,使得我们对</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">的定制可以立即生效(无需重启</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">)。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-size: large"><span style="font-family: 宋体">使</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">中文化</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">在</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">顶部增加下列文本:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" disable VI's compatible mode..</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set nocompatible</span></span></p><span></span><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" set encoding=utf-8</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set fileencodings=ucs-bom,utf-8,gbk,default,latin1</span></span></p><span></span><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" use chinese help</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set helplang=cn</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">上述<a href="javascript:;" target="_self" onclick="javascript:tagshow(event, '%B4%FA%C2%EB');"><u><strong>代码</strong></u></a>的作用是禁用</span><span><span style="font-family: Calibri">vi</span></span><span style="font-family: 宋体">兼容模式(原始的</span><span><span style="font-family: Calibri">vi</span></span><span style="font-family: 宋体">功能太少了,没必要考虑兼容)、按照</span><span><span style="font-family: Calibri">utf-8</span></span><span style="font-family: 宋体">、</span><span><span style="font-family: Calibri">gbk</span></span><span style="font-family: 宋体">的顺序来检测文件编码,并设置帮助为中文。不过设置</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">set helplang=cn</span></span></span><span></span><span style="font-family: 宋体">并不能马上看到中文帮助,我们还得下载中文帮助文件。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://vimcdoc.sourceforge.net/"><span style="font-size: small; font-family: Calibri">http://vimcdoc.sourceforge.net/</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><span style="font-family: Calibri">vimcdoc-1.6.0.tar.gz</span></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt; text-align: left" class="MsoNormal" align="left"><span style="font-size: small"><span style="font-family: 宋体">得到中文帮助文件压缩包后,将压缩包中</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">doc</span></span></span><span></span><span style="font-family: 宋体">子目录的所有文件复制到</span><span class="MsoSubtleReference"><span><span style="color: #c0504d; font-family: Verdana">$VIM\vimfiles\doc</span></span></span><span></span><span style="font-family: 宋体">目录中。此时再输入</span><strong><span><span style="color: #ff0000">:help</span></span></strong><span></span><span style="font-family: 宋体">命令就可以看到中文帮助了。</span></span></p><p style="margin: 12pt 0cm 7.8pt; text-align: center" class="MsoNormal" align="center"><span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">中文帮助还是</span><span><span style="font-family: Calibri">7.1</span></span><span style="font-family: 宋体">版的,不过不影响我们使用。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-family: 宋体"><span style="font-size: large">设置字体</span></span></h3><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">选择</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">菜单的“编辑”</span><span><span style="font-family: Calibri">-></span></span><span style="font-family: 宋体">“选择字体”,就可以为</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">指定喜欢的显示字体了。笔者使用的是</span><span style="font-family: Calibri"><span>Consolas</span></span><span style="font-family: 宋体">字体,大小设置为</span><span><span style="font-family: Calibri">9pt</span></span><span style="font-family: 宋体">。这个设置显示代码非常漂亮,不过中文就有点变形了。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">设置好后,输入命令</span><strong><span><span style="color: #ff0000">:set guifont</span></span></strong><span></span><span style="font-family: 宋体">可以查看到当前的字体设置,将该设置写入</span><span style="font-family: Calibri"><span>_vimrc</span></span><span style="font-family: 宋体">文件。</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">"set gui options</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">if has("gui_running")</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small"><span style="color: #244061"><span style="font-family: Consolas"><span> </span>set guifont=Consolas:h9</span></span></span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">endif</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">上述代码中的</span><span><span style="font-family: Calibri">if … endif</span></span><span style="font-family: 宋体">是一个条件判断结构。指示只有当我们使用图形界面版的</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">时才设置字体。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-size: large"><span style="font-family: 宋体">为编辑</span><span><span style="font-family: Calibri">PHP</span></span><span style="font-family: 宋体">代码进行基本设置</span></span></h3><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">现在用</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">打开</span><span><span style="font-family: Calibri">.php</span></span><span style="font-family: 宋体">文件看上去是很难看的,别说代码高亮,连行号都没有显示。所以还要给</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">添加以下内容:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Enable syntax highlight</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">syntax enable</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Show line number</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set nu</span></span></p><span></span><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" show matching bracets</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set showmatch</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Basic editing options</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set expandtab</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set shiftwidth=2</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">au FileType html,python,vim,javascript setl shiftwidth=2</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">au FileType html,python,vim,javascript setl tabstop=2</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">au FileType java,php setl shiftwidth=4</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">au FileType java,php setl tabstop=4</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set smarttab</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set lbr</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set tw=0</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">"Auto indent</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set ai</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Smart indet</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set si</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" C-style indeting</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set cindent</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Wrap lines</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set wrap</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">上述设置启用了格式化高亮、行号显示,以及括号匹配、自动缩进等编辑功能,对于大多数情况都可以获得理想的编辑体验。不过此时对</span><span><span style="font-family: Calibri">.php</span></span><span style="font-family: 宋体">文件的支持还不完善,需要下载专门的</span><span><span style="font-family: Calibri">php</span></span><span style="font-family: 宋体">插件。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://www.vim.org/scripts/script.php?script_id=1571"><span style="font-size: small; font-family: Calibri">http://www.vim.org/scripts/script.php?script_id=1571</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><span style="font-family: Calibri">php.tar.gz</span></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">将其中的</span><span><span style="font-family: Calibri">php.vim</span></span><span style="font-family: 宋体">复制到</span><span><span style="font-family: Calibri">$VIM\vimfiles\syntax</span></span><span style="font-family: 宋体">目录中即可。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-family: 宋体"><span style="font-size: large">设置喜欢的配色方案</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">默认的配色方案相信没几个人会喜欢,可以通过下面的网址查看配色方案并下载(有几百个哦)。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">下载网址:</span><span><a href="http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-c.html"><span style="font-family: Calibri">http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-c.html</span></a></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">这个网址列出了</span><span><span style="font-family: Calibri">300</span></span><span style="font-family: 宋体">多个配色方案以及实际的显示效果,点击方案名称即可下载到一个</span><span><span style="font-family: Calibri">.vim</span></span><span style="font-family: 宋体">文件。将该文件放入</span><span><span style="font-family: Calibri">$VIM\vimfiles\colors</span></span><span style="font-family: 宋体">目录,然后在</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">中添加:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" set color schema</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">colorscheme oceandeep</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">这两行代码需要加到</span><span style="font-family: Calibri"><span>if has("gui_running") … endif</span></span><span style="font-family: 宋体">代码块中,例如:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">if has("gui_running")</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small"><span style="color: #244061"><span style="font-family: Consolas"><span> </span>set guifont=Consolas:h9</span></span></span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small"><span style="color: #244061"><span style="font-family: Consolas"><span> </span>" set color schema</span></span></span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small"><span style="color: #244061"><span style="font-family: Consolas"><span> </span>colorscheme oceandeep</span></span></span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">endif</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">设置后显示效果就漂亮多了</span><span><span style="font-family: Calibri">:-)</span></span></span><span><span style="font-size: small; font-family: Calibri">­</span></span></p><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-family: 宋体"><span style="font-size: large">更多有用的编辑设置</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt; text-align: left" class="MsoNormal" align="left"><span style="font-size: small"><span style="font-family: 宋体">虽然不是专门针对编辑</span><span><span style="font-family: Calibri">.php</span></span><span style="font-family: 宋体">文件的设置,但这些选项可以让</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">更好用,所以建议加上:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Sets how many lines of history VIM har to remember</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set history=400</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Set to auto read when a file is changed from the outside</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set autoread</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Have the mouse enabled all the time:</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set mouse=a</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Do not redraw, when running macros.. lazyredraw</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set lz</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" set 7 lines to the curors - when moving vertical..</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set so=7</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" The commandbar is 2 high</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set cmdheight=2</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Change buffer - without saving</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set hid</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Ignore case when searching</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" set ignorecase</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set incsearch</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Set magic on</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set magic</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" No sound on errors.</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set noerrorbells</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set novisualbell</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set t_vb=</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" How many tenths of a second to blink</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set mat=4</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Highlight search things</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set hlsearch</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" Turn backup off</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set nobackup</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set nowb</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set noswapfile</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" smart backspace</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">set backspace=start,indent,eol</span></span></p><span><span style="font-size: small; color: #244061; font-family: Consolas"> </span></span> <p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" switch buffers with Tab</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">map <C-Tab> :bn<CR></span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">map <S-Tab> :bp<CR></span></span></p></div><span><span style="font-size: small; font-family: Calibri"> </span></span> <p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt; text-align: left" class="MsoNormal" align="left"><span style="font-size: small"><span style="font-family: 宋体">经过一番改造,我们的</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">已经可以很顺手的编辑</span><span><span style="font-family: Calibri">.php</span></span><span style="font-family: 宋体">文件了。不过要打造</span><span><span style="font-family: Calibri">php</span></span><span style="font-family: 宋体">开发环境还有很多<a href="javascript:;" target="_self" onclick="javascript:tagshow(event, '%B9%A4%D7%F7');"><u><strong>工作</strong></u></a>要做呢。</span></span></p><span></span><h2 style="margin: 13pt 0cm 7.8pt"><span style="font-family: 宋体">打造</span><span><span style="font-family: Cambria">PHP IDE</span></span></h2><p style="margin: 0cm 0cm 7.8pt" class="MsoNormal"></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span><span style="font-family: Calibri">IDE</span></span><span style="font-family: 宋体">左侧是目录导航,中间是编辑区域,而右侧则是<a href="javascript:;" target="_self" onclick="javascript:tagshow(event, '%B7%BD%B7%A8');"><u><strong>方法</strong></u></a>列表,用于在已经打开的文件中快速跳转。在编辑区域按下</span><span style="font-family: Calibri"><span>CTRL+X</span></span><span style="font-family: 宋体">键,还会显示已打开文件的列表。</span></span></p><p style="margin: 0cm 0cm 7.8pt" class="MsoNormal"></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">其他诸如自动补全、代码模板等功能,都应有尽有。看过了漂亮的截图,我们就来一步步打造</span><span><span style="font-family: Calibri">PHP IDE</span></span><span style="font-family: 宋体">吧。</span></span></p><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-size: large"><span style="font-family: 宋体">用</span><span><span style="font-family: Calibri">NERDTree</span></span><span style="font-family: 宋体">实现目录导航</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">在进行</span><span><span style="font-family: Calibri">PHP</span></span><span style="font-family: 宋体">应用开发时,同时编辑多个文件是很正常的事情。所以必须有一个方便的目录导航工具,以便在目录结构间快速切换,找到需要编辑的文件。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">中提供该类功能的插件很多,比较知名的有</span><span><span style="font-family: Calibri">project</span></span><span style="font-family: 宋体">、</span><span><span style="font-family: Calibri">winmanager</span></span><span style="font-family: 宋体">等。但笔者个人认为最好用的还是</span><span><span style="font-family: Calibri">The NERD Tree</span></span><span style="font-family: 宋体">这个插件。</span><span><span style="font-family: Calibri">NERDTree</span></span><span style="font-family: 宋体">不但可以显示完整的目录树结构,还可以将任何一个目录设置为根目录。并且提供了目录导航的书签功能,可谓非常方便。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://www.vim.org/scripts/script.php?script_id=1658"><span style="font-size: small; font-family: Calibri">http://www.vim.org/scripts/script.php?script_id=1658</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><span style="font-family: Calibri">NERD_tree.zip</span></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">解压缩时,要把压缩包中的目录结构完整的解压缩到</span><span><span style="font-family: Calibri">$VIM\vimfiles</span></span><span style="font-family: 宋体">目录中。完成后,应该分别找到</span><span style="font-family: Calibri"><span>$VIM\vimfiles\doc\NERD_tree.txt</span></span><span style="font-family: 宋体">文件和</span><span><span style="font-family: Calibri">$VIM\vimfiles\plugin\NERD_tree.vim</span></span><span style="font-family: 宋体">文件。然后在</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">中输入命令</span><strong><span><span style="color: #ff0000">:helptags $VIM\vimfiles\doc</span></span></strong><span style="font-family: 宋体">,将</span><span><span style="font-family: Calibri">NERDTree</span></span><span style="font-family: 宋体">的帮助文档添加到</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">中。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">最后在</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">添加如下内容:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" NERDTree</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">map <F10> :NERDTreeToggle<CR></span></span></p></div><span style="font-size: small"><span style="font-family: 宋体">重启</span><span><span style="font-family: Calibri">vim</span></span><span style="font-family: 宋体">后,按下</span><span><span style="font-family: Calibri">F10</span></span><span style="font-family: 宋体">键,就可以在左侧看到一个目录树了。在目录树窗口中按下</span><span><span style="font-family: Calibri">?</span></span><span style="font-family: 宋体">键可以查看详细的帮助信息。</span></span><span><span style="font-size: small; font-family: Calibri"> </span></span> <p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">最常用的操作键有:</span></span></p><p></p><table border="1" cellspacing="1" cellpadding="1" width="531" style="width: 531px; height: 179px"><tbody><tr><td> <strong><span style="color: #365f91; font-family: 宋体">按键</span><span style="color: #365f91"></span></strong></td><td> <strong><span style="color: #365f91; font-family: 宋体">作用</span><span style="color: #365f91"></span></strong></td></tr><tr><td> <strong><span style="color: #365f91"><span style="font-family: Calibri">C</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">(大写</span><span style="color: #365f91"><span style="font-family: Calibri">C</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">键)</span><span style="color: #365f91"></span></strong></td><td> <span style="color: #365f91; font-family: 宋体">将光标所在目录设置为根目录</span><span style="color: #365f91"></span></td></tr><tr><td> <strong><span style="color: #365f91"><span style="font-family: Calibri">u</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">(小写</span><span style="color: #365f91"><span style="font-family: Calibri">u</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">键)</span><span style="color: #365f91"></span></strong></td><td> <span style="color: #365f91; font-family: 宋体">转到上一级目录</span><span style="color: #365f91"></span></td></tr><tr><td> <strong><span style="color: #365f91"><span style="font-family: Calibri">o</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">(小写</span><span style="color: #365f91"><span style="font-family: Calibri">o</span></span></strong><strong><span style="color: #365f91; font-family: 宋体">键,不是“零”)</span><span style="color: #365f91"></span></strong></td><td> <span style="color: #365f91; font-family: 宋体">展开(或折叠)光标所在目录的子目录。如果光标所在位置是一个文件,则在编辑窗口中打开该文件</span><span style="color: #365f91"></span></td></tr></tbody></table><span></span><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">此外在目录树窗口中输入目录</span><span style="color: #ff0000"><strong><span>:Bookmark</span></strong><strong><span style="font-family: 宋体">收藏名</span></strong></span><span style="font-family: 宋体">还可以将光标所在目录添加到收藏夹中。下次使用</span><span style="color: #ff0000"><strong><span>:BookmarkToRoot</span></strong><strong><span style="font-family: 宋体">收藏名</span></strong></span><span style="font-family: 宋体">可以直接转到该目录,并且以该目录作为根目录。更多命令可以参考</span><span><span style="font-family: Calibri">NERDTree</span></span><span style="font-family: 宋体">的帮助文档。</span></span></p><span></span><h3 style="margin: 13pt 0cm 7.8pt 21pt"><span style="font-size: large"><span style="font-family: 宋体">用</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">实现代码导航</span></span></h3><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">解决了目录和文件导航问题,我们还要为代码之间的跳转提供辅助手段,</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">就是这样一个插件。</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">可以列出已打开文件中定义的类、函数、常量,甚至变量。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://www.vim.org/scripts/script.php?script_id=273"><span style="font-size: small; font-family: Calibri">http://www.vim.org/scripts/script.php?script_id=273</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><span style="font-family: Calibri">taglist_45.zip</span></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">压缩包需要完整解压缩到</span><span><span style="font-family: Calibri">$VIM\vimfiles</span></span><span style="font-family: 宋体">目录,并且用</span><strong><span><span style="color: #ff0000">:helptags $VIM\vimfiles\doc</span></span></strong><span></span><span style="font-family: 宋体">命令索引</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">插件的帮助文档。</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">插件需要依赖</span><span><span style="font-family: Calibri">ctags</span></span><span style="font-family: 宋体">程序才能工作。目前常用的</span><span><span style="font-family: Calibri">ctags</span></span><span style="font-family: 宋体">版本是</span><span><span style="font-family: Calibri">Exuberant Ctags</span></span><span style="font-family: 宋体">。</span></span></p><p style="margin: 0cm 0cm 7.8pt 21pt" class="MsoNormal"><span style="font-family: 宋体"><span style="font-size: small">下载地址:</span></span><span><a href="http://ctags.sourceforge.net/"><span style="font-size: small; font-family: Calibri">http://ctags.sourceforge.net/</span></a><span style="font-size: small; font-family: Calibri"><br /></span></span><span style="font-size: small"><span style="font-family: 宋体">下载文件:</span><span><span style="font-family: Calibri">ec57w32.zip</span></span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">只需要把压缩包中的</span><span><span style="font-family: Calibri">ctags.exe</span></span><span style="font-family: 宋体">复制到</span><span><span style="font-family: Calibri">$VIM\vim72</span></span><span style="font-family: 宋体">目录中即可。</span><span><span style="font-family: Calibri">ctags.exe</span></span><span style="font-family: 宋体">应该和</span><span><span style="font-family: Calibri">gvim.exe</span></span><span style="font-family: 宋体">在一个目录。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">最后在</span><span><span style="font-family: Calibri">_vimrc</span></span><span style="font-family: 宋体">添加下列内容,设置好</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">插件:</span></span></p><div style="border-right: medium none; padding-right: 0cm; border-top: medium none; padding-left: 4pt; padding-bottom: 0cm; margin-left: 21pt; border-left: 1pt solid; margin-right: 21pt; padding-top: 0cm; border-bottom: medium none"><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" => Plugin configuration</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">" taglist</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Auto_Highlight_Tag = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Auto_Open = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Auto_Update = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Close_On_Select = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Compact_Format = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Display_Prototype = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Display_Tag_Scope = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Enable_Fold_Column = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Exit_OnlyWindow = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_File_Fold_Auto_Close = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_GainFocus_On_ToggleOpen = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Hightlight_Tag_On_BufEnter = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Inc_Winwidth = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Max_Submenu_Items = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Max_Tag_Length = 30</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Process_File_Always = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Show_Menu = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Show_One_File = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Sort_Type = "order"</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Use_Horiz_Window = 0</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_Use_Right_Window = 1</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let Tlist_WinWidth = 40</span></span></p><p style="margin: 0cm 0cm 0pt" class="code"><span><span style="font-size: small; color: #244061; font-family: Consolas">let tlist_php_settings = 'php;c:class;i:interfaces;d:constant;f:function'</span></span></p></div><p style="margin: 12pt 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">这里的设置是笔者个人习惯的设置,大家在熟悉</span><span><span style="font-family: Calibri">taglist</span></span><span style="font-family: 宋体">的具体设置之前可以先尝试一下。</span></span></p><p style="margin: 0cm 0cm 7.8pt; text-indent: 21pt" class="MsoNormal"><span style="font-size: small"><span style="font-family: 宋体">设置完成后,在编辑</span><span><span style="font-family: Calibri">.php</span></span></span></p>
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/1304/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2012-3-18 15:11
评论列表