"=============================================================================
" General settings
"=============================================================================
set nocp
" Tab related
set ts=4
set sw=4
set smarttab
set et
set ambiwidth=double
" Format related
set tw=78
set lbr
set fo+=mB
" Indent related
set cin
set ai
set cino=:0g0t0(susj1
" Editing related
set backspace=indent,eol,start
set whichwrap=b,s,<,>,[,]
set mouse=a
set selectmode=
set mousemodel=popup
set keymodel=
set selection=inclusive
" Misc
set wildmenu
set spell
" Encoding related
set encoding=utf-8
set langmenu=zh_CN.UTF-8
language message zh_CN.UTF-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
" File type related
filetype plugin indent on
" Display related
set ru
set sm
set hls
if (has("gui_running"))
set guioptions+=b
colo torte
set nowrap
else
colo ron
set wrap
endif
syntax on
" ============================================================================
" Shortcuts
" ============================================================================
" 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!>
imap <C-F12> <C-o>:set nu!>
" Toggle spell check
" For VIM7 only
nmap <C-F11> :setlocal spell!>
imap <C-F11> <C-o>:setlocal spell!>
"=============================================================================
" Modes
"=============================================================================
function EnglishMode()
"set imactivatekey=
"set noimcmdline
"set iminsert=0
"set imsearch=0
setlocal spell
endfunction
command -nargs=0 EnglishMode call EnglishMode()
function ChineseMode()
"set imactivatekey=C-space
"set noimcmdline
"set iminsert=2
"set imsearch=2
setlocal nospell
endfunction
command -nargs=0 ChineseMode call ChineseMode()
function TextMode()
setlocal nocin
setlocal nosm
setlocal noai
setlocal tw=78
endfunction
command -nargs=0 TextMode call TextMode()
function CodeMode()
setlocal cin
setlocal sm
setlocal ai
setlocal tw=78
endfunction
command -nargs=0 CodeMode call CodeMode()
function MailMode()
call TextMode()
setlocal ft=mail
setlocal tw=70
endfunction
command -nargs=0 MailMode call MailMode()
function BBSMode()
call MailMode()
call ChineseMode()
setlocal ft=bbs
setlocal fenc=cp936
setlocal tw=78
endfunction
command -nargs=0 BBSMode call BBSMode()
function VikiMode()
call ChineseMode()
setlocal ft=viki
endfunction
command -nargs=0 VikiMode call VikiMode()
"=============================================================================
" Functions
"=============================================================================
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
" Replace once and never update.
%s/Created: *$/\=strftime("Created: %Y-%m-%d %H:%M:%S")/ge
call RestoreWinPosn(curposn)
endfunction
command -nargs=0 TimeStamp call TimeStamp()
function AutoTimeStamp()
augr tagdate
au!
au BufWritePre,FileWritePre * call TimeStamp()
augr END
endfunction
command -nargs=0 AutoTimeStamp call AutoTimeStamp()
function NoAutoTimeStamp()
augr tagdate
au!
augr END
endfunction
command -nargs=0 NoAutoTimeStamp call NoAutoTimeStamp()
command -nargs=1 Margin exec "match Error /.\\%>" . (<args> + 1) . "v/"
command -nargs=0 NoMargin match none
function CodeLayout()
call CodeMode()
WManager
Tlist
endfunction
command -nargs=0 CodeLayout call CodeLayout()
function CodeLayoutSmall()
call CodeLayout()
set columns=141
exec "norm \<c-w>l"
set nu
set lines=100
endfunction
command -nargs=0 CodeLayoutSmall call CodeLayoutSmall()
function CodeLayoutLarge()
call CodeLayout()
set columns=226
exec "norm \<c-w>l"
set nu
vsplit
set lines=100
endfunction
command -nargs=0 CodeLayoutLarge call CodeLayoutLarge()
" ============================================================================
" Plugins settings
" ============================================================================
" Sketch
command -nargs=0 ToggleSketch call ToggleSketch()
" Tlist
let Tlist_Use_Right_Window=1
let Tlist_File_Fold_Auto_Close=1
" A
let g:alternateNoDefaultAlternate=1
let g:alternateRelativeFiles=1
" Viki
let g:vikiNameSuffix=".viki"
BufRead,BufNewFile *.viki call VikiMode()
" BBS
autocmd! BufRead,BufNewFile *.bbs call BBSMode()
" Mail
FileType mail call MailMode()
" FencView
let g:fencview_autodetect=0
"=============================================================================
" Platform dependent settings
"=============================================================================
if (has("win32"))
"-------------------------------------------------------------------------
" Win32
"-------------------------------------------------------------------------
if (has("gui_running"))
set guifont=Bitstream_Vera_Sans_Mono:h9:cANSI
set guifontwide=NSimSun:h9:cGB2312
endif
" For Viki
let g:netrw_browsex_viewer="start"
" For tee
set shellpipe=2>&1\|\ tee
" VimTweak
if (has("gui_running"))
command -nargs=1 SetAlpha call libcallnr("vimtweak.dll",
\"SetAlpha", <args>)
command -nargs=0 TopMost call libcallnr("vimtweak.dll",
\"EnableTopMost", 1)
command -nargs=0 NoTopMost call libcallnr("vimtweak.dll",
\"EnableTopMost", 0)
endif
else
"-------------------------------------------------------------------------
" Linux
"-------------------------------------------------------------------------
if (has("gui_running"))
set guifont=Bitstream\ Vera\ Sans\ Mono\ 9
endif
" For Viki
let g:vikiHomePage="~/document/Viki/index.viki"
let g:netrw_browsex_viewer="kfmclient exec"
set makeprg=build
endif
|