我的Vim配置

From:http://www.cnblogs.com/strugglever/

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" cscope setting begin

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"初始化,自动载入cscope索引数据库

if has("cscope")

set csprg=/usr/local/bin/cscope

set csto=1

set cst

set nocsverb

" add any database in current directory

if filereadable("cscope.out")

cs add cscope.out

endif

set csverb

endif

 

"使用quick fix窗口显示查询结果

" set cscopequickfix=s-,c-,d-,i-,t-,e-

 

"自动创建更新cscope索引数据库

"定义:alias csvim='export CSCOPEROOT=`pwd`;vim',在启动vim之前导入自定义CSCOPEROOT环境变量。

"必须保证有对目录进行写的权限

autocmd BufWritePost,FileWritePost $CSCOPEROOT/*.h,$CSCOPEROOT/*.c,$CSCOPEROOT/*.cpp,$CSCOPEROOT/*.sh,$CSCOPEROOT/*.lua !echo "run";if [ -d "$CSCOPEROOT" ];then echo "$CSCOPEROOT is a directory.";find $CSCOPEROOT -name "*.h" -o -name "*.c" -o -name "*.cpp" -o -name "*.lua" -o -name "*.sh" > $CSCOPEROOT/cscope.files;cscope -bqU -i CSCOPEROOT/cscope.files;echo "successfully build or update cscope database."; else echo "$CSCOPEROOT is not a directory."; fi

 

"快捷键--原窗口打开

nmap \s :cs find s <C-R>=expand("<cword>")<cr><cr>

nmap \t :cs find t <C-R>=expand("<cword>")<cr><cr>

nmap \e :cs find e <C-R>=expand("<cword>")<cr><cr>

nmap \g :cs find g <C-R>=expand("<cword>")<cr><cr>

nmap \c :cs find c <C-R>=expand("<cword>")<cr><cr>

nmap \d :cs find d <C-R>=expand("<cword>")<cr><cr>

nmap \f :cs find f <C-R>=expand("<cfile>")<cr><cr>

nmap \i :cs find i <C-R>=expand("<cfile>")<cr><cr>

"快捷键--新窗口打开

nmap \\s :scs find s <C-R>=expand("<cword>")<cr><cr>

nmap \\t :scs find t <C-R>=expand("<cword>")<cr><cr>

nmap \\e :scs find e <C-R>=expand("<cword>")<cr><cr>

nmap \\g :scs find g <C-R>=expand("<cword>")<cr><cr>

nmap \\c :scs find c <C-R>=expand("<cword>")<cr><cr>

nmap \\d :scs find d <C-R>=expand("<cword>")<cr><cr>

nmap \\f :scs find f <C-R>=expand("<cfile>")<cr><cr>

nmap \\i :scs find i <C-R>=expand("<cfile>")<cr><cr>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" cscope setting end

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

 

"""---编辑类---"""

"自动缩进

set autoindent

set cindent

"缩进空格数(<<和>>命令)

"set shiftwidth=4

"自动补全配对

inoremap <> <><ESC>i

inoremap () ()<ESC>i

inoremap {} {<CR>}<ESC>O

inoremap [] []<ESC>i

inoremap "" ""<ESC>i

inoremap '' ''<ESC>i

"自动插入避免头文件重复包含的宏定义

inoremap <F12> <ESC>Go#endif<ESC>ggO#ifndef <CR>#define <UP>

 

"""---状态类---"""

"高亮显示当前行

set cursorline

"显示行号

set number

"光标行列位置显示

set ruler

 

"""---语法高亮---"""

syntax enable

syntax on

 

"""---控制类---"""

"自动滚屏

set scrolloff=20

"避免退格键不响应

"indent:删除缩进

"eol:删除行结束符

"start:删除在本次插入前的输入的字符

set backspace=indent,eol,start

 

"""---搜索类---"""

"增量搜索

set incsearch

"高亮搜索

set hlsearch

"搜索忽略大小写

set ignorecase smartcase

 

"---编码--- "

" fileencoding是被动设置的

set encoding=utf-8 fileencodings=ucs-bom,utf-8,gbk,gb18030,latin1

 

"开启折叠功能

"set fdm=indent

 

"---编译---"

set makeprg=$MAKEPRG

posted on 2011-07-16 17:42  strugglEver  阅读(215)  评论(0)    收藏  举报