Last Change:
if v:version < 700
echoerr 'This _vimrc requires Vim 7 or later.'
quit
endif
if has('autocmd')
au!
endif
if has('gui_running')
let do_syntax_sel_menu=1
endif
if has('multi_byte')
let legacy_encoding=&encoding
endif
if has('gui_running') && has('multi_byte')
if $LANG !~ '\.' || $LANG =~? '\.UTF-8$'
set encoding=utf-8
else
let &encoding=matchstr($LANG, '\.\zs.*')
let legacy_encoding=&encoding
endif
endif
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
if has('gui_running')
source $VIMRUNTIME/mswin.vim
unmap <C-Y>|
iunmap <C-A>|
nmap <C-Tab> :tabn<CR>
imap <C-Tab> <C-O>:tabn<CR>
nmap <C-S-Tab> :tabp<CR>
imap <C-S-Tab> <C-O>:tabp<CR>
nmap <C-Down> <C-W>w
imap <C-Down> <C-O><C-W>w
nmap <C-Up> <C-W>W
imap <C-Up> <C-O><C-W>W
endif
set autoindent
set nobackup
set formatoptions+=mM
set fileencodings=ucs-bom,utf-8,default,latin1
set grepprg=grep\ -nH
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P
set dictionary+=~\vimfiles\words
set tags+=~\vimfiles\systags
set directory=~\AppData\Local\Temp
set path=.,
\,
if has("directx") && $VIM_USE_DIRECTX != '0'
set renderoptions=type:directx
let s:use_directx=1
endif
if &shell =~? 'cmd'
set shellpipe=2>&1\|\ tee
endif
if &shell =~? '^[^"].* .*[^"]'
let &shell='"' . &shell . '"'
endif
if has('syntax')
set spelllang=en_gb
endif
if has('persistent_undo')
set undodir=~\AppData\Local\Temp\vim_undo_files
set undofile
endif
if has('eval')
function! FindRuntimeFile(filename, ...)
if a:0 != 0 && a:1 =~ 'w'
let require_writable=1
else
let require_writable=0
endif
let runtimepaths=&runtimepath . ','
while strlen(runtimepaths) != 0
let filepath=substitute(runtimepaths, ',.*', '', '') . '/' . a:filename
if filereadable(filepath)
if !require_writable || filewritable(filepath)
return filepath
endif
endif
let runtimepaths=substitute(runtimepaths, '[^,]*,', '', '')
endwhile
return ''
endfunction
function! EchoCharCode()
let char_enc=matchstr(getline('.'), '.', col('.') - 1)
let char_fenc=iconv(char_enc, &encoding, &fileencoding)
let i=0
let len=len(char_fenc)
let hex_code=''
while i < len
let hex_code.=printf('%.2x',char2nr(char_fenc[i]))
let i+=1
endwhile
echo '<' . char_enc . '> Hex ' . hex_code . ' (' .
\(&fileencoding != '' ? &fileencoding : &encoding) . ')'
endfunction
nmap <silent> gn :call EchoCharCode()<CR>
function! GoToFirstNonBlankOrFirstColumn()
let cur_col=col('.')
normal! ^
if cur_col != 1 && cur_col == col('.')
normal! 0
endif
return ''
endfunction
nmap <silent> <Home> :call GoToFirstNonBlankOrFirstColumn()<CR>
imap <silent> <Home> <C-R>=GoToFirstNonBlankOrFirstColumn()<CR>
function! InsertCurrentDate()
let curr_date=strftime('%Y-%m-%d', localtime())
return curr_date
endfunction
imap <silent> <C-\><C-D> <C-R>=InsertCurrentDate()<CR>
endif
noremap <C-J> gj
noremap <C-K> gk
inoremap <M-Home> <C-O>g0
inoremap <M-End> <C-O>g$
nnoremap <silent> <Leader>ma yypV:!calcu <C-R>"<CR>k$
vnoremap <silent> <Leader>ma yo<Esc>pV:!calcu <C-R>"<CR>k$
nnoremap <silent> <Leader>mr yyV:!calcu <C-R>"<CR>$
vnoremap <silent> <Leader>mr ygvmaomb:r !calcu <C-R>"<CR>"ay$dd`bv`a"ap
xnoremap < <gv
xnoremap > >gv
nmap S :%s//g<Left><Left>
xmap S :s//g<Left><Left>
nnoremap ZX :confirm qa<CR>
nmap <unique> <silent> <Leader>co <Plug>ClipBrdOpen
nmap <silent> <F2> :nohlsearch<CR>
imap <silent> <F2> <C-O>:nohlsearch<CR>
nmap <silent> <F3> :set fdl=1 fdm=syntax<bar>syn sync fromstart<CR>
nmap <C-F3> zv
nmap <M-F3> zc
nmap <silent> <F4> :if &list == 0<bar>
\exec "set listchars=tab:\uBB\u2014,trail:\uB7,nbsp:~"<bar>
\set list<bar>
\echo "Display of TAB and trailing SPACE turned on"<bar>
\else<bar>
\set nolist<bar>
\echo<bar>
\endif<CR>
nmap <silent> <F5> :if &background == 'light'<bar>
\colorscheme bandit<bar>
\set background=dark<bar>
\echo<bar>
\else<bar>
\colorscheme default<bar>
\set background=light<bar>
\echo<bar>
\endif<CR>
nmap <silent> <F6> :if &laststatus == 1<bar>
\set laststatus=2<bar>
\echo<bar>
\else<bar>
\set laststatus=1<bar>
\endif<CR>
nmap <F9> :Tlist<CR>
imap <F9> <C-O>:Tlist<CR>
nmap <F11> :cn<CR>
nmap <F12> :cp<CR>
nmap <M-F11> :copen<CR>
nmap <M-F12> :cclose<CR>
nmap <C-F11> :tn<CR>
nmap <C-F12> :tp<CR>
nmap <S-F11> :n<CR>
nmap <S-F12> :prev<CR>
<URL:https://docs.google.com/file/d/0Bx3f0gFZh5Jqc0MtcUstV3BKdTQ/>
nmap <Leader>l :call ListTrans_toggle_format()<CR>
vmap <Leader>l :call ListTrans_toggle_format('visual')<CR>
<URL:https://docs.google.com/file/d/0Bx3f0gFZh5Jqc0MtcUstV3BKdTQ/>
Warning: "gv"
xmap <expr> ++ VMATH_YankAndAnalyse()
nmap ++ vip++
<URL:https://docs.google.com/file/d/0Bx3f0gFZh5Jqc0MtcUstV3BKdTQ/>
if has('gui_running')
xmap <expr> <Left> DVB_Drag('left')
xmap <expr> <Right> DVB_Drag('right')
xmap <expr> <Down> DVB_Drag('down')
xmap <expr> <Up> DVB_Drag('up')
else
xmap <expr> <S-Left> DVB_Drag('left')
xmap <expr> <S-Right> DVB_Drag('right')
xmap <expr> <S-Down> DVB_Drag('down')
xmap <expr> <S-Up> DVB_Drag('up')
endif
<URL:http://clang.llvm.org/docs/ClangFormat.html>
function! UseClangFormat()
map <buffer> <silent> <Tab> :pyf C:/Program\ Files\ (x86)/LLVM/share/clang/clang-format.py<CR>
imap <buffer> <silent> <C-F> <ESC>:pyf C:/Program\ Files\ (x86)/LLVM/share/clang/clang-format.py<CR>i
endfunction
function! ParagraphToLine()
normal! ma
if &formatoptions =~ 'w'
let reg_bak=@"
normal! G$vy
if @" =~ '\s'
normal! o
endif
let @"=reg_bak
silent! %s/\(\S\)$/\1\r/e
else
normal! Go
endif
silent! g/\S/,/^\s*$/j
silent! %s/\s\+$//e
normal! `a
endfunction
if !has('gui_running')
language messages en
if has('eval')
let Tlist_Inc_Winwidth=0
endif
if has('wildmenu')
set wildmenu
set cpoptions-=<
set wildcharm=<C-Z>
nmap <F10> :emenu <C-Z>
imap <F10> <C-O>:emenu <C-Z>
endif
if &termencoding != '' && &termencoding != &encoding
let &encoding=&termencoding
let &fileencodings='ucs-bom,utf-8,' . &encoding
endif
endif
if has('gui_running') && has('statusline')
let &statusline=substitute(
\&statusline, '%=', '%=%{winwidth(0)}x%{winheight(0)} ', '')
set laststatus=2
endif
if has('gui_running') && has('multi_byte')
function! UTF8_East()
exec 'language messages ' . s:lang_east . '.UTF-8'
set ambiwidth=double
set encoding=utf-8
let s:utf8_east_mode=1
endfunction
function! UTF8_West()
exec 'language messages ' . s:lang_west . '.UTF-8'
set ambiwidth=single
set encoding=utf-8
let s:utf8_east_mode=0
endfunction
function! UTF8_SwitchMode()
if exists('b:utf8_east_mode')
unlet b:utf8_east_mode
endif
if s:utf8_east_mode
call UTF8_West()
call UTF8_SetFont()
else
call UTF8_East()
call UTF8_SetFont()
endif
endfunction
function! UTF8_SetFont()
if &encoding != 'utf-8'
return
endif
if &fileencoding == 'cp936' ||
\&fileencoding == 'gbk' ||
\&fileencoding == 'euc-cn'
let s:font_east=s:font_schinese
elseif &fileencoding == 'cp950' ||
\&fileencoding == 'big5' ||
\&fileencoding == 'euc-tw'
let s:font_east=s:font_tchinese
elseif &fileencoding == 'cp932' ||
\&fileencoding == 'sjis' ||
\&fileencoding == 'euc-jp'
let s:font_east=s:font_japanese
elseif &fileencoding == 'cp949' ||
\&fileencoding == 'euc-kr'
let s:font_east=s:font_korean
endif
if !exists('s:use_directx') && (
\(g:legacy_encoding == 'cp936' && s:font_east == s:font_schinese) ||
\(g:legacy_encoding == 'cp950' && s:font_east == s:font_tchinese) ||
\(g:legacy_encoding == 'cp932' && s:font_east == s:font_japanese) ||
\(g:legacy_encoding == 'cp949' && s:font_east == s:font_korean))
let s:font_east=''
endif
if exists('b:utf8_east_mode') && s:utf8_east_mode != b:utf8_east_mode
let s:utf8_east_mode=b:utf8_east_mode
let &ambiwidth=(s:utf8_east_mode ? 'double' : 'single')
endif
if s:utf8_east_mode
exec 'set guifont=' . s:font_east
set guifontwide=
else
exec 'set guifont=' . s:font_west
exec 'set guifontwide=' . s:font_east
endif
endfunction
function! UTF8_CheckAndSetFont()
if &fileencoding == 'cp936' ||
\&fileencoding == 'gbk' ||
\&fileencoding == 'euc-cn' ||
\&fileencoding == 'cp950' ||
\&fileencoding == 'big5' ||
\&fileencoding == 'euc-tw' ||
\&fileencoding == 'cp932' ||
\&fileencoding == 'sjis' ||
\&fileencoding == 'euc-jp' ||
\&fileencoding == 'cp949' ||
\&fileencoding == 'euc-kr'
let b:utf8_east_mode=1
elseif &fileencoding == 'latin1' ||
\&fileencoding =~ 'iso-8859-.*' ||
\&fileencoding =~ 'koi8-.' ||
\&fileencoding == 'macroman' ||
\&fileencoding == 'cp437' ||
\&fileencoding == 'cp850' ||
\&fileencoding =~ 'cp125.' ||
\&fileencoding =~ 'windows-125.'
let b:utf8_east_mode=0
endif
if exists('b:utf8_east_mode') &&
\(b:utf8_east_mode || (!b:utf8_east_mode && s:utf8_east_mode)) &&
\((s:utf8_east_mode && &guifont == s:font_east) ||
\(!s:utf8_east_mode && &guifont == s:font_west))
call UTF8_SetFont()
endif
endfunction
function UTF8_SwitchDejaVu()
if s:font_west =~ '^Courier_New'
let s:font_west='DejaVu_Sans_Mono:h10:cDEFAULT'
else
let s:font_west='Courier_New:h10:cDEFAULT'
endif
call UTF8_SetFont()
endfunction
<URL:http://tinyurl.com/2hnwaq>
"zh_CN.UTF-8"
let s:font_schinese='NSimSun:h12:cDEFAULT'
let s:font_tchinese='MingLiU:h12:cDEFAULT'
let s:font_japanese='MS_Gothic:h12:cDEFAULT'
let s:font_korean='GulimChe:h12:cDEFAULT'
if legacy_encoding == 'cp936'
let s:font_east=s:font_schinese
elseif legacy_encoding == 'cp950'
let s:font_east=s:font_tchinese
elseif legacy_encoding == 'cp932'
let s:font_east=s:font_japanese
elseif legacy_encoding == 'cp949'
let s:font_east=s:font_korean
else
let s:font_east=s:font_schinese
endif
let s:font_west='Courier_New:h10:cDEFAULT'
if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
let s:lang_east=matchstr(v:lang, '^[a-zA-Z_]*\ze\(\.\|$\)')
let s:lang_west='en'
let s:utf8_east_mode=1
if v:lang=~? '^zh_TW'
let s:font_east=s:font_tchinese
elseif v:lang=~? '^ja'
let s:font_east=s:font_japanese
elseif v:lang=~? '^ko'
let s:font_east=s:font_korean
endif
else
let s:lang_east='zh_CN'
let s:lang_west=matchstr(v:lang, '^[a-zA-Z_]*\ze\(\.\|$\)')
let s:utf8_east_mode=0
endif
if &encoding == 'utf-8'
if s:utf8_east_mode && $VIM_USE_DIRECTX == '0'
call UTF8_East()
else
call UTF8_West()
endif
elseif s:utf8_east_mode
exec 'set guifont=' . s:font_east
else
exec 'set guifont=' . s:font_west
endif
call UTF8_SetFont()
nmap <F8> :call UTF8_SwitchMode()<CR>
imap <F8> <C-O>:call UTF8_SwitchMode()<CR>
nmap <C-F8> :call UTF8_SwitchDejaVu()<CR>
imap <C-F8> <C-O>:call UTF8_SwitchDejaVu()<CR>
nmap <silent> <S-F8> :if &linespace == 1<bar>
\set linespace=3<bar>
\else<bar>
\set linespace=1<bar>
\endif<CR>
if has('autocmd')
au BufWinEnter,WinEnter * call UTF8_CheckAndSetFont()
endif
endif
if has('syntax')
nmap <silent> <F7> :setlocal spell!<CR>
imap <silent> <F7> <C-O>:setlocal spell!<CR>
let spellfile_path=FindRuntimeFile('spell/en.' . &encoding . '.add', 'w')
if spellfile_path != ''
exec 'nmap <M-F7> :sp ' . spellfile_path . '<CR><bar><C-W>_'
endif
endif
iabbrev Br Best regards,
iabbrev Btw By the way,
iabbrev Yw Yongwei
if has('autocmd')
function! Timezone()
if has('python')
import time
def my_timezone():
is_dst = time.daylight and time.localtime().tm_isdst
offset = time.altzone if is_dst else time.timezone
(hours, seconds) = divmod(abs(offset), 3600)
hours = -hours if offset > 0 else hours
minutes = seconds // 60
return '{:+03d}{:02d}'.format(hours, minutes)
return ' ' . pyeval('my_timezone()')
else
return ''
endif
endfunction
function! SetFileEncodings(encodings)
let b:my_fileencodings_bak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:my_fileencodings_bak
unlet b:my_fileencodings_bak
endfunction
function! GnuIndent()
if &filetype == 'c' || &filetype == 'cpp'
setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
setlocal shiftwidth=2
setlocal tabstop=8
endif
endfunction
function! UpdateLastChangeTime()
let last_change_anchor='^\(" Last Change:\s\+\)\d\{4}-\d\{2}-\d\{2} \d\{2}:\d\{2}:\d\{2}\( [-+]\d\{4}\)\?'
let last_change_line=search(last_change_anchor, 'n')
if last_change_line != 0
let last_change_time=strftime('%Y-%m-%d %H:%M:%S', localtime())
let last_change_text=substitute(getline(last_change_line), last_change_anchor, '\1', '') . last_change_time . Timezone()
call setline(last_change_line, last_change_text)
endif
endfunction
function! RemoveTrailingSpace()
if $VIM_HATE_SPACE_ERRORS != '0' &&
\(&filetype == 'c' || &filetype == 'cpp' || &filetype == 'vim')
normal! m`
silent! :%s/\s\+$//e
normal! ``
endif
endfunction
if legacy_encoding != 'latin1'
let &fileencodings=substitute(
\&fileencodings, '\<default\>', legacy_encoding, '')
else
let &fileencodings=substitute(
\&fileencodings, ',default,', ',', '')
endif
let MRU_File=$HOME . '\_vim_mru_files'
let MRU_Exclude_Files='\\itsalltext\\.*\|\\temp\\.*'
let MRU_Max_Entries=30
let VEConf_systemEncoding=legacy_encoding
let CVScmdencoding=legacy_encoding
let CVSfileencoding='utf-8'
let clang_user_options='-std=c++11'
let $FENCVIEW_TELLENC='tellenc' <URL:http://wyw.dcweb.cn/>
let fencview_autodetect=1
let fencview_auto_patterns='*.c,*.cpp,*.cs,*.h,*.log,*.txt,*.tex,'
\.'*.vim,*.htm{l\=},*.asp,'
\.'README,CHANGES,INSTALL'
let fencview_html_filetypes='html,aspvbs'
let EchoFuncLangsUsed=['c', 'cpp']
let NERDMapleader='<Leader>c'
let NERDMenuMode=0
let NERDShutUp=1
if $VIM_HATE_SPACE_ERRORS != '0'
let c_space_errors=1
endif
let c_gnu=1
let c_no_curly_error=1
unlet c_comment_strings
let load_doxygen_syntax=1
<URL:http://ftp.gnome.org/pub/GNOME/sources/ttf-bitstream-vera/1.10/>
let doxygen_use_bitsream_vera=1
let html_use_css=1
map <Leader>a :call SyntaxAttr()<CR>
au FileType c,cpp call UseClangFormat()|
\setlocal expandtab cinoptions=:0,g0 shiftwidth=4 softtabstop=4 tabstop=4
au FileType cs setlocal expandtab shiftwidth=4 softtabstop=4
au FileType python setlocal expandtab shiftwidth=4 softtabstop=4
au FileType diff setlocal shiftwidth=4 tabstop=4
au FileType changelog setlocal textwidth=76
au FileType cvs setlocal textwidth=72
au FileType html,xhtml setlocal indentexpr=
au FileType mail setlocal expandtab softtabstop=2 textwidth=70 comments+=fb:* comments-=mb:*
au FileType markdown setlocal autoindent expandtab linebreak formatoptions=tcqlmn
au BufReadPre *.gb call SetFileEncodings('cp936')
au BufReadPre *.big5 call SetFileEncodings('cp950')
au BufReadPre *.nfo call SetFileEncodings('cp437')
au BufReadPost *.gb,*.big5,*.nfo call RestoreFileEncodings()
au BufRead *.txt if &buftype=='help'|nmap <buffer> q <C-W>c|endif
au BufEnter C:/mingw* call GnuIndent()
au BufWritePre *vimrc,*.vim call UpdateLastChangeTime()
au BufWritePre * call RemoveTrailingSpace()
endif