" 项目: gvim 配置文件
" 作者:
" 安装: sudo apt-get install vim-gtk
" 用法: 将本文件(.vimrc)拷贝到$HOME/
colorscheme desert
" 使用 murphy 调色板
" set nocompatible
" 设定文件浏览器目录为当前目录
set bsdir=buffer
set autochdir
" 设置编码
set enc=utf-8
" 设置文件编码
set fenc=utf-8
" 设置文件编码检测类型及支持格式
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
" 指定菜单语言
set langmenu=zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" 设置语法高亮度
set syn=cpp
"显示行号
set nu!
" 查找结果高亮度显示
set hlsearch
" tab宽度
set tabstop=4
set cindent shiftwidth=4
set autoindent shiftwidth=4
" CC++注释
set comments=://
" 修正自动C式样注释功能 <20050716>
set comments=s1:*,mb:*,ex0:/
" 增强检索功能
set tags=.tags,...tags,./**/tags
" 保存文件格式
set fileformats=unix,dos
" 键盘操作
map gk
map gj
" 命令行高度
set cmdheight=1
" 中文帮助
if version > 603
set helplang=cn
:colorscheme desert
" let Tlist_Use_Right_Window=1
" let Tlist_File_Fold_Auto_Close=1
"""""""""""使用cscope
if has("cscope")
set csprg=/usr/local/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
set cscopetag
set cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-
endif
endi
"=============================================================================
" General settings
"=============================================================================
set nocp
set ru
set cin
set sm
set ai
set sw=4
set ts=4
set et
set cino=:0g0t0(sus
set lbr
set hls
set backspace=indent,eol,start
set whichwrap=b,s,<,>,[,]
set fo+=mB
set selectmode=
set mousemodel=popup
set keymodel=
set selection=inclusive
" for gdbvim
set noshowcmd
" Encoding settings
if 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
endif
else
echoerr "Sorry, this version of (g)vim was not compiled with multi_byte"
endif
" Cursor movement
nnoremap gj
nnoremap gk
vnoremap gj
vnoremap gk
inoremap gj
inoremap gk
nnoremap g$
nnoremap g0
vnoremap g$
vnoremap g0
inoremap g$
inoremap g0
nmap :confirm bd
vmap :confirm bd
omap :confirm bd
map! :confirm bd
" Move lines
nmap :move .+1
nmap :move .-2
imap :move .+1
imap :move .-2
vmap :move '>+1gv
vmap :move '<-2gv
" Toggle line number
nmap :set nu!
imap :set nu!
" Toggle spell check
" For VIM7 only
nmap :set spell!
imap :set spell!
syntax on
if (has("gui_running"))
set nowrap
set guioptions+=b
colo desert
else
set wrap
colo desert
endif
" ============================================================================
" Plugins settings
" ============================================================================
" Sketch
command -nargs=0 ToggleSketch call ToggleSketch()
" WinManar
let g:winManagerWindowLayout = "BufExplorer,FileExplorer|TagList"
nmap wm :WMToggle
" Tlist
" let Tlist_Use_Right_Window=1
" let Tlist_File_Fold_Auto_Close=1
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
" MiniBufExplorer
let g:miniBufExplMapWindowNavVim = 1
" A
let g:alternateNoDefaultAlternate=1
" VIM7 doesn't support this.
"let g:alternateExtensions_{"aspx"} = "aspx.cs,aspx.CS"
"let g:alternateExtensions_{"aspx.cs"} = "aspx,ASPX"
" LateXSuite
filetype plugin on
set grepprg=grep/ -nH/ $*
" Viki
let g:vikiNameSuffix=".viki"
augr viki
au!
au BufRead,BufNewFile *.viki set filetype=viki
augr END
"=============================================================================
" Functions
"=============================================================================
function TextWork()
set nocin
set nosm
set noai
set tw=78
set sw=8
set ts=8
set nowrap
endfunction
function NoTextWork()
set cin
set sm
set ai
set tw=0
set sw=4
set ts=4
if (!has("gui_running"))
set wrap
endif
endfunction
function CodeWork()
call NoTextWork()
WManar
Tlist
endfunction
function TimeStamp()
let curposn= SaveWinPosn()
%s/
%s
%s
call RestoreWinPosn(curposn)
endfunction
function AutoTimeStamp()
augr tagdate
au!
au BufWritePre,FileWritePre * call TimeStamp()
augr END
endfunction
call AutoTimeStamp()
function NoAutoTimeStamp()
augr tagdate
au!
augr END
endfunction
"=============================================================================
" 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
"-----------------------------------------------------------------------------
" Calender
let 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 Template
function MailWork()
0r ~documenttextmailtemp.txt
%s%%date%%/=strftime("%Y-%m-%d")
%s%%cursor%%
call TextWork()
endfunction
command -nargs=0 MailWork call MailWork()
" Use kittiemake as the default compiler
function Kittie()
set makeprg=kittiemake
endfunction
command -nargs=0 Kittie call Kittie()
" Don't use kittiemake as the default compiler
function NoKittie()
set makeprg=make
endfunction
command -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 END
let 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.vim
endif