1. 字体,色彩背景设置
$ vi ~/.vimrc
” set font and color
if has(“gui_running”)
set guifont=Courier\ 10\ Pitch\ 12
“set gfw=幼圆:h12:cGB2312
colorscheme koehler
endif
2. ctags
查询变量、函数的定义
$ pwd
~/workspace/project1
$ ctags -R
在vim中:set tags=~/work/project1/tags,之后就可以通过C+]查询变量、函数的定义,在通过C+t回到原位。
在编程中,想直接查找并跳转到头文件的定义,使用
$ ctags -I __THROW -I __attribute_pure__ -I __nonnull -I __attribute__ –file-scope=yes –langmap=c:+.h –languages=c,c++ –links=yes –c-kinds=+p –c++-kinds=+p –fields=+iaS –extra=+q -R -f ~/.vim/systags /usr/src/linux-headers-2.6.32-5-common/include/
$ set tags+=~/.vim/systags
3. taglist
可以在左侧窗口,查看宏定义、变量、函数定义等。点击左侧相应项目,按回车自动跳转到相应定义地方,如果只想查看定义信息,不想跳转,则按空格键。
在http://www.vim.org/scripts/script.php?script_id=273下载taglist_45.zip,并解压到~/vim目录下。
$ unzip -d ~/.vim
$ vi ~/.vimrc
” set Tlist
let Tlist_Show_One_File = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Process_File_Always = 1 “实时更新
在vi中,通过:Tlist打开。
4. cscope
查找变量,函数等的定义
$ cscope -Rbq
$ ls
cscope.in.out cscope.out cscope.po.out
在VI中
$ :cs add cscope.out . <—把刚才生成的cscope文件导入到vim中,必须加.,否则当有子目录源码时,无法使用。
$ :cs find g kpipe_init <—跳转到kpipe_init处
$ :cs find c kpipe_init <—查看kpipe_init被调用了几次
cscope的主要功能是通过同的子命令”find”来实现的
cscope find的用法:
cs find c|d|e|f|g|i|s|t name
0 或 s 查找本 C 符号(可以跳过注释)
1 或 g 查找本定义
2 或 d 查找本函数调用的函数
3 或 c 查找调用本函数的函数
4 或 t 查找本字符串
6 或 e 查找本 egrep 模式
7 或 f 查找本文件
8 或 i 查找包含本文件的文件
5. QuickFix
$ cw <—显示QuickFix窗口
$ cn <—下一条结果
$ cp <—上一条结果
6. WinManager
文件浏览器和窗口管理器,下载:http://www.vim.org/scripts/script.php?script_id=95
$ vi ~/.vimrc
” set winManager
let g:winManagerWindowLayout=’FileExplorer|TagList’
nmap wm :WMToggle<cr>
7. MiniBufExplorer
快速浏览和操作Buffer,下载:http://www.vim.org/scripts/script.php?script_id=159
” set minibuf
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1 “在gvim中通过C+Tab在buffer之间进行跳转
let g:miniBufExplModSelTarget = 1
let g:miniBufExplMaxSize = 1
8. supertab
tab键智能补全,下载:http://www.vim.org/scripts/script.php?script_id=182
$ vi supertab.vba
:so %
9. c.vim
下载:http://www.vim.org/scripts/script.php?script_id=213
$ cd ~/.vim
$ unzip ~/Soft/vim_plugin/cvim.zip
c.vim插件有8个特性,分别介绍如下:
1)自动给.c程序添加文件头说明
打开下面的文件,并根据自己的情况进行相应修改。
$ vi .vim/c-support/templates/Templates
2)自动添加函数模板,包括函数说明
在VI中,输入\if,输入函数名,比如:test_release,会生成如下所示的函数说明模板
/*
* === FUNCTION =====================================================================
* Name: test_release
* Description:
* ====================================================================
*/
void test_release ( <+argument list+> )
{
return <+return value+>;
} /* —– end of function test_release —– */
3)插入主函数
在VI中,输入\im,加入如下模板:
#include <stdlib.h>
/*
* === FUNCTION ======================================================================
* Name: main
* Description:
* ====================================================================
*/
int main ( int argc, char *argv[] )
{
return EXIT_SUCCESS;
} /* ———- end of function main ———- */
4)插入函数说明
在VI中,输入\cfu
5)插入一帧注释
在VI中,输入\cfr
6)包含头文件
在VI中,输入\p<
7)保存文件,编译并执行
保存并编译文件用\rc
执行使用\rr
8)插入预先定义好的代码片段
在VI中,输入\nr
10. vim-autocomplpop
自动弹出补全提示选项,下载:http://www.vim.org/scripts/download_script.php?src_id=11894
$ unzip Desktop/vim-autocomplpop.zip -d ~/.vim
本文介绍了如何通过配置和安装各种插件将 Vim 打造成一个功能强大的集成开发环境 (IDE)。具体包括字体颜色设置、ctags 和 cscope 的使用、taglist 和 QuickFix 等增强功能。
184

被折叠的 条评论
为什么被折叠?



