gvim 开发环境配置文件

来源:互联网 发布:wince音乐播放软件 编辑:程序博客网 时间:2024/06/10 00:46
" 项目: gvim 配置文件" 作者: " 安装: sudo apt-get install vim-gtk" 用法: 将本文件(.vimrc)拷贝到$HOME/colorscheme desert" 使用 murphy 调色板" set nocompatible" 设定文件浏览器目录为当前目录set bsdir=bufferset autochdir" 设置编码set enc=utf-8" 设置文件编码set fenc=utf-8" 设置文件编码检测类型及支持格式set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" 指定菜单语言set langmenu=zh_CN.UTF-8source $VIMRUNTIME/delmenu.vimsource $VIMRUNTIME/menu.vim" 设置语法高亮度set syn=cpp"显示行号set nu!" 查找结果高亮度显示set hlsearch" tab宽度set tabstop=4set cindent shiftwidth=4set autoindent shiftwidth=4" CC++注释set comments=://" 修正自动C式样注释功能 <20050716>set comments=s1:*,mb:*,ex0:/" 增强检索功能set tags=.tags,...tags,./**/tags" 保存文件格式set fileformats=unix,dos" 键盘操作map gkmap gj" 命令行高度set cmdheight=1" 中文帮助if version > 603set helplang=cn:colorscheme desert" let Tlist_Use_Right_Window=1" let Tlist_File_Fold_Auto_Close=1"""""""""""使用cscopeif has("cscope")set csprg=/usr/local/bin/cscopeset csto=0set cstset nocsverb" add any database in current directoryif filereadable("cscope.out")cs add cscope.out" else add database pointed to by environmentelseif $CSCOPE_DB != ""cs add $CSCOPE_DBendifset csverbset cscopetagset cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-endifendi"=============================================================================" General settings"=============================================================================set nocpset ruset cinset smset aiset sw=4set ts=4set etset cino=:0g0t0(susset lbrset hlsset backspace=indent,eol,startset whichwrap=b,s,<,>,[,]set fo+=mBset selectmode=set mousemodel=popupset keymodel=set selection=inclusive" for gdbvimset noshowcmd" Encoding settingsif has("multi_byte") " Set fileencoding priority if getfsize(expand("%")) > 0 set fileencodings=ucs-bom,utf-8,cp936,big5,euc-jp,euc-kr,latin1 else set fileencodings=cp936,big5,euc-jp,euc-kr,latin1 endif " CJK environment detection and corresponding setting if v:lang =~ "^zh_CN" " Use cp936 to support GBK, euc-cn == gb2312 set encoding=cp936 set termencoding=cp936 set fileencoding=cp936 elseif v:lang =~ "^zh_TW" " cp950, big5 or euc-tw " Are they equal to each other? set encoding=big5 set termencoding=big5 set fileencoding=big5 elseif v:lang =~ "^ko" " Copied from someone's dotfile, untested set encoding=euc-kr set termencoding=euc-kr set fileencoding=euc-kr elseif v:lang =~ "^ja_JP" " Copied from someone's dotfile, unteste set encoding=euc-jp set termencoding=euc-jp set fileencoding=euc-jp endif " Detect UTF-8 locale, and replace CJK setting if needed if v:lang =~ "utf8$" || v:lang =~ "UTF-8$" set encoding=utf-8 set termencoding=utf-8 set fileencoding=utf-8 endifelse echoerr "Sorry, this version of (g)vim was not compiled with multi_byte"endif" Cursor movementnnoremap gjnnoremap gkvnoremap gjvnoremap gkinoremap gjinoremap gknnoremap g$nnoremap g0vnoremap g$vnoremap g0inoremap g$inoremap g0nmap :confirm bdvmap :confirm bdomap :confirm bdmap! :confirm bd" Move linesnmap :move .+1nmap :move .-2imap :move .+1imap :move .-2vmap :move '>+1gvvmap :move '<-2gv" Toggle line numbernmap :set nu!imap :set nu!" Toggle spell check" For VIM7 onlynmap :set spell!imap :set spell!syntax onif (has("gui_running")) set nowrap set guioptions+=b colo desertelse set wrap colo desertendif" ============================================================================" Plugins settings" ============================================================================" Sketchcommand -nargs=0 ToggleSketch call ToggleSketch()" WinManarlet g:winManagerWindowLayout = "BufExplorer,FileExplorer|TagList"nmap wm :WMToggle" Tlist" let Tlist_Use_Right_Window=1" let Tlist_File_Fold_Auto_Close=1let Tlist_Show_One_File=1let Tlist_Exit_OnlyWindow=1" MiniBufExplorerlet g:miniBufExplMapWindowNavVim = 1 " Alet g:alternateNoDefaultAlternate=1" VIM7 doesn't support this."let g:alternateExtensions_{"aspx"} = "aspx.cs,aspx.CS""let g:alternateExtensions_{"aspx.cs"} = "aspx,ASPX"" LateXSuitefiletype plugin onset grepprg=grep/ -nH/ $*" Vikilet g:vikiNameSuffix=".viki"augr vikiau!au BufRead,BufNewFile *.viki set filetype=vikiaugr END"=============================================================================" Functions"=============================================================================function TextWork() set nocin set nosm set noai set tw=78 set sw=8 set ts=8 set nowrapendfunctionfunction NoTextWork() set cin set sm set ai set tw=0 set sw=4 set ts=4 if (!has("gui_running")) set wrap endifendfunctionfunction CodeWork() call NoTextWork() WManar Tlistendfunctionfunction TimeStamp() let curposn= SaveWinPosn() %s/ %s %s call RestoreWinPosn(curposn)endfunctionfunction AutoTimeStamp() augr tagdate au! au BufWritePre,FileWritePre * call TimeStamp() augr ENDendfunctioncall AutoTimeStamp()function NoAutoTimeStamp() augr tagdate au! augr ENDendfunction"=============================================================================" Commands"=============================================================================command -nargs=0 TextWork call TextWork()command -nargs=0 NoTextWork call NoTextWork()command -nargs=0 CodeWork call CodeWork()command -nargs=0 TimeStamp call TimeStamp()command -nargs=0 AutoTimeStamp call AutoTimeStamp()command -nargs=0 NoAutoTimeStamp call NoAutoTimeStamp()"=============================================================================" Platform dependent settings"============================================================================="-----------------------------------------------------------------------------" Common"-----------------------------------------------------------------------------" Calenderlet g:calendar_diary="homemessiahdocument/diary"" Spell Check" VIM7 supports built-in spell check."function SpellCheck()" !aspell --lang=en -c %"endfunction"command -nargs=0 SpellCheck call SpellCheck()" Mail Templatefunction MailWork() 0r ~documenttextmailtemp.txt %s%%date%%/=strftime("%Y-%m-%d") %s%%cursor%% call TextWork()endfunctioncommand -nargs=0 MailWork call MailWork()" Use kittiemake as the default compilerfunction Kittie() set makeprg=kittiemakeendfunctioncommand -nargs=0 Kittie call Kittie()" Don't use kittiemake as the default compilerfunction NoKittie() set makeprg=makeendfunctioncommand -nargs=0 NoKittie call NoKittie()"-----------------------------------------------------------------------------" Win32"-----------------------------------------------------------------------------"if (has("gui_running"))" set guifont=YaHei/ Consolas/ Hybrid/ 12"endif" For LaTeX Suite"let g:Tex_CompileRule_dvi="latex -src-specials -interaction=nonstopmode $*""set shellslash" For tee"set shellpipe=2>&1/|/ tee" VimTweak"if (has("gui_running"))" command -nargs=1 SetAlpha call libcallnr("vimtweak.dll"," /"SetAlpha", )" command -nargs=0 TopMost call libcallnr("vimtweak.dll"," /"EnableTopMost", 1)" command -nargs=0 NoTopMost call libcallnr("vimtweak.dll"," /"EnableTopMost", 0)"endif"-----------------------------------------------------------------------------" Linux"-----------------------------------------------------------------------------"For LaTeX Suite"function RemoteLaTeX()" let g:Tex_ViewRule_dvi="xdvi -editor 'gvim --servername /""" /.expand("%:p")."/" --remote-silent'"" augr remotelatex" au!" augr END"endfunction"augr remotelatex"au!"au BufRead * call RemoteLaTeX()"augr ENDlet g:Tex_CompileRule_dvi /="latex -src-specials -interaction=nonstopmode $*"let g:Tex_ViewRule_dvi /="xdvi -editor 'gvim --servername latex-suite --remote-silent'"if (has("gui_running")) set guifont=YaHei/ Consolas/ Hybrid/ 12 source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vimendif