以下是滇狐自己的 .vimrc,有许多根据滇狐自己的习惯做的设置,如果你要在自己机器上使用的话,请根据你自己的习惯作出相应修改。

另外,这份 .vimrc 里面有许多设置是针对插件的,只有安装了相应插件后,这些配置才会起作用。这里有滇狐使用的全部插件打包,如果需要的话可以直接下载,Linux 用户将该压缩包解压到 $HOME 目录下即可使用,Windows 用户可以将压缩包解压后,将解压得到的 .vim 文件夹改名为 vimfiles,然后复制到 VIM 的安装路径下,覆盖原有文件。

"=============================================================================
" General settings
"=============================================================================

set nocp

" Tab related
set ts=4
set sw=4
set smarttab
set et
set ambiwidth=double

" Format related
set tw=80
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

set list
set listchars=tab:»\ ,trail:,extends:»,precedes:«
highlight SpecialKey ctermbg=Red guibg=Red

" File type related
filetype plugin indent on

" Persistent undo
if v:version >= 703
    set undodir=$HOME/.vimundodir
    set colorcolumn=+1
endif

" Display related
set ru
set sm
set hls
if (has("gui_running"))
    set guioptions-=m
    set guioptions-=T
    set guioptions+=b
    if $USER == "root"
        colo peachpuff
    else
        colo torte
    endif
    set nowrap
else
    if $USER == "root"
        colo shine
    else
        colo ron
    endif
    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!<CR>
imap <C-F12> <C-o>:set nu!<CR>

" Toggle spell check
" For VIM7 only
nmap <C-F11> :setlocal spell!<CR>
imap <C-F11> <C-o>:setlocal spell!<CR>

"=============================================================================
" Modes
"=============================================================================

function EnglishMode()
    setlocal spell
    setlocal formatexpr=
endfunction
command -nargs=0 EnglishMode call EnglishMode()

function ChineseMode()
    setlocal nospell
    setlocal formatexpr=autofmt#japanese#formatexpr()
endfunction
command -nargs=0 ChineseMode call ChineseMode()

function TextMode()
    setlocal nocin
    setlocal nosi
    setlocal noai
    setlocal tw=80
endfunction
command -nargs=0 TextMode call TextMode()

function CodeMode()
    setlocal cin
    setlocal si
    setlocal ai
    setlocal tw=80
endfunction
command -nargs=0 CodeMode call CodeMode()

function MailMode()
    call TextMode()
    setlocal tw=70
endfunction
command -nargs=0 MailMode setlocal ft=mail

function BBSMode()
    call MailMode()
    call ChineseMode()
    setlocal tw=76
endfunction
command -nargs=0 BBSMode setlocal ft=bbs

function VikiMode()
    call ChineseMode()
    setlocal ft=viki
endfunction
command -nargs=0 VikiMode call VikiMode()

"=============================================================================
" Functions
"=============================================================================

function QuoteFix()
    %s/^\(> \?\)*>/\=substitute(submatch(0), " ", "", "g")/ge
    g/^\(> \?\)\+\s*$/d
endfunction
command -nargs=0 QuoteFix call QuoteFix()

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(c)
    call CodeLayout()
    let &columns=a:c
    exec "norm \<c-w>t"
    set winfixwidth
    exec "norm \<c-w>j"
    set winfixwidth
    set winfixheight
    exec "norm \<c-w>l"
    set nu
    set lines=56
    exec "norm \<c-w>b"
    set winfixwidth
    exec "norm \<c-w>t"
    exec "norm \<c-w>l"
endfunction
command -nargs=0 CodeLayoutSmall call CodeLayoutSmall(141)

function CodeLayoutLarge(c)
    call CodeLayout()
    let &columns=a:c
    exec "norm \<c-w>t"
    set winfixwidth
    exec "norm \<c-w>j"
    set winfixwidth
    set winfixheight
    exec "norm \<c-w>l"
    set nu
    vsplit
    set lines=76
    exec "norm \<c-w>b"
    set winfixwidth
    exec "norm \<c-w>t"
    exec "norm \<c-w>l"
endfunction
command -nargs=0 CodeLayoutLarge call CodeLayoutLarge(226)

function TtySize()
    set columns=80
    set lines=24
endfunction
command -nargs=0 TtySize call TtySize()

" ============================================================================
" 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"

" FencView
let g:fencview_autodetect=0

" showmarks
let g:showmarks_enable=0
let g:showmarks_include="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
let g:showmarks_hlline_lower=1
let g:showmarks_hlline_upper=1

" autofmt
let s:unicode = unicode#import()
let s:orig_prop_line_break = s:unicode.prop_line_break
functions:unicode.prop_line_break(char)
    if a:char == "\u201c" || a:char == "\u2018"
        return "OP"   " Open Punctuation
    elseif a:char == "\u201d" || a:char == "\u2019"
        return "CL"   " Close Punctuation
    endif
    return call(s:orig_prop_line_break, [a:char], self)
endfunction

"=============================================================================
" File types
"=============================================================================

augr filetype
    " BBS
    auBufRead,BufNewFile *.bbs BBSMode
    " Mail
    auFileType mail call MailMode()
    " Viki
    auBufRead,BufNewFile *.viki VikiMode
augr end

"=============================================================================
" Platform dependent settings
"=============================================================================

if (has("win32"))

    "-------------------------------------------------------------------------
    " Win32
    "-------------------------------------------------------------------------

    if (has("gui_running"))
        set guifont=DejaVu_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=DejaVu\ Sans\ Mono\ 9
    endif

    " For Viki
    let g:vikiHomePage="~/Documents/Viki/index.viki"
    let g:netrw_browsex_viewer="kfmclient exec"

    set makeprg=build

endif

set nomousehide
标签:VIM .vimrc 源代码