天天看点

windows下gvim配置文件

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let eq = ''
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      let cmd = '""' . $VIMRUNTIME . '\diff"'
      let eq = '"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction

"###################
syntax enable "打开语法高亮
syntax on "自动语法高亮

set autoindent "自动对齐
set cindent "设置使用C/C++语言的自动缩进方式
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s "设置C/C++语言的具体缩进方式

set autochdir "自动切换当前目录为当前文件所在的目录
set nocompatible "设置为nocompatible模式

set smarttab 
set tabstop=4 "设置tab键为4个空格
set showmatch "设置匹配模式,如括号等
set softtabstop=4 "使得按退格键时可以一次删掉 4 个空格
set shiftwidth=4       "自动缩进宽度
set nu "加入行号显示
set mouse=a "添加鼠标支持

colorscheme green_light "配置颜色主题
filetype on "文件类型支持
filetype plugin on     "enables filetype specific plugins
filetype indent on "为特定文件类型载入相关缩进文件
set incsearch " 输入搜索内容时就显示搜索结果
set hlsearch " 搜索时高亮显示被找到的文本
set smartindent "根据上面的对齐格式,智能的选择对齐方式

"相关文件设置
set nobackup   "不要备份文件
setlocal noswapfile   "不生成swap文件

" 配置多语言环境,解决中文乱码问题
if has("multi_byte")
    " UTF-8 编码
    set encoding=utf-8
    set termencoding=utf-8
    set formatoptions+=mM
    set fencs=utf-8,gbk
    if v:lang =~? '^/(zh/)/|/(ja/)/|/(ko/)'
        set ambiwidth=double
    endif
    if has("win32")
        source $VIMRUNTIME/delmenu.vim
        source $VIMRUNTIME/menu.vim
        language messages zh_CN.utf-8
    endif
else
    echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
endif

"编码相关配置
set encoding=utf-8   "GVIM内部编码
set fileencoding=utf-8   "当前编辑的文件编码
set fileencodings=utf-8,gbk,gb2312,big5,latin1  "GVIM支持打开的文件编码

" ======= 引号 && 括号自动匹配 ======= "
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
:inoremap ` ``<ESC>i

function ClosePair(char)
	if getline('.')[col('.') - 1] == a:char
		return "\<Right>"
    else
       return a:char
    endif
endf

"一些常用键的映射
" Ctrl + H            将光标移到当前行的行首
imap <c-h> <ESC>I
" Ctrl + J            将光标移到下一行的行首
imap <c-j> <ESC>jI
" Ctrl + K            将光标移到上一行的末尾
imap <c-k> <ESC>kA
" Ctrl + L            将光标移到当前行的行尾
imap <c-l> <ESC>A

"Tlist工具快捷键,按F3呼出
map <F3> :silent! Tlist<CR>


"自动补全,7.3版本已自动开启
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete

"ctags插件配置,跳转到函数定义,目前功能不正常 by zs 2013-1-4
"set tags=tags;

"python代码补全插件,目前没有开启,使用neocomplcache命令补全插件
"let g:pydiction_location = 'D:\Program Files\Vim\vimfiles\ftplugin\pydiction\complete-dict'
"let g:pydiction_menu_height = 10 "设置弹出菜单的高度,默认是15

"Python 文件的一般设置,比如不要 tab 等
"autocmd FileType python set tabstop=4 shiftwidth=4 expandtab

"对NERD_commenter的设置
"let NERDShutUp=1
let NERDSpaceDelims=1 "在注释的开头和末尾都添加一个空格来美观一下

"neocomplcache命令补全插件
let g:neocomplcache_enable_at_startup=1

"补全作者信息插件 authorinfo.vim
let g:vimrc_author='zs'
let g:vimrc_email='[email protected]'
let g:vimrc_homepage='http://blog.csdn.net/findtime/'
"map <F4> :AuthorInfoDetect<CR>  "设置添加头部注释的快捷键