分类: LINUX
2006-02-25 10:43:18
以下是滇狐自己的 .vimrc, 有许多根据滇狐自己的习惯做的设置, 如果你要在自己机器上使用的话, 请根据你自己的习惯作出相应修改。
另外, 这份 .vimrc 里面有许多设置是针对插件的, 只有安装了相应插件后, 这些配置才会起作用。 有滇狐使用的全部插件打包, 如果需要的话可以直接下载, Linux 用户将该压缩包解压到 $HOME 目录下即可使用, Windows 用户可以将压缩包解压后, 将解压得到的 .vim 文件夹改名为 vimfiles, 然后复制到 VIM 的安装路径下, 覆盖原有文件。
"=============================================================================
" 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 <Down> gj
nnoremap <Up> gk
vnoremap <Down> gj
vnoremap <Up> gk
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
nnoremap <End> g$
nnoremap <Home> g0
vnoremap <End> g$
vnoremap <Home> g0
inoremap <End> <C-o>g$
inoremap <Home> <C-o>g0
nmap <C-F4> :confirm bd<CR>
vmap <C-F4> <ESC>:confirm bd
omap <C-F4> <ESC>:confirm bd
map! <C-F4> <ESC>:confirm bd
" Move lines
nmap <C-Down> :<C-u>move .+1<CR>
nmap <C-Up> :<C-u>move .-2<CR>
imap <C-Down> <C-o>:<C-u>move .+1<CR>
imap <C-Up> <C-o>:<C-u>move .-2<CR>
vmap <C-Down> :move '>+1<CR>gv
vmap <C-Up> :move '<-2<CR>gv
" Toggle line number
nmap <C-F12> :set nu!<CR>
imap <C-F12> <C-o>:set nu!<CR>
" Toggle spell check
" For VIM7 only
nmap <C-F11> :set spell!<CR>
imap <C-F11> <C-o>:set spell!<CR>
syntax on
if (has("gui_running"))
set nowrap
set guioptions+=b
colo torte
else
set wrap
colo ron
endif
" ============================================================================
" Plugins settings
" ============================================================================
" Sketch
command -nargs=0 ToggleSketch call ToggleSketch()
" WinManager
" let g:winManagerWindowLayout = "FileExplorer"
" Tlist
let Tlist_Use_Right_Window=1
let Tlist_File_Fold_Auto_Close=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()
WManager
Tlist
endfunction
function TimeStamp()
let curposn= SaveWinPosn()
%s/\$Date: .*\$/\=strftime("$Date: %Y-%m-%d %H:%M:%S$")/ge
%s/Last Change: .*$/\=strftime("Last Change: %Y-%m-%d %H:%M:%S")/ge
%s/Last Modified: .*$/\=strftime("Last Modified: %Y-%m-%d %H:%M:%S")/ge
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="/home/edward/document/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 ~/document/text/mailtemp.txt
%s/%%date%%/\=strftime("%Y-%m-%d")/ge
%s/%%cursor%%//ge
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=新宋体:h9:cGB2312
"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=Bitstream\ Vera\ Sans\ Mono\ 9
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
endif