My _vimrc Posted on 2019-06-26 _vimrc 我的配置文件 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123"中文乱码set fileencodings=utf-8,ucs-bom,cp936,big5set fileencoding=utf-8source $VIMRUNTIME/vimrc_example.vimsource $VIMRUNTIME/mswin.vimbehave mswinset diffexpr=MyDiff()function MyDiff() let opt = '-a --binary ' if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif let arg1 = v:fname_in if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif let arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif if $VIMRUNTIME =~ ' ' if &sh =~ '\<cmd' if empty(&shellxquote) let l:shxq_sav = '' set shellxquote& endif let cmd = '"' . $VIMRUNTIME . '\diff"' else let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' endif else let cmd = $VIMRUNTIME . '\diff' endif silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 if exists('l:shxq_sav') let &shellxquote=l:shxq_sav endifendfunction" mineset nu!colorscheme eveningsyntax enablesyntax onset nobackup "不生成备份文件set ai "设置自动缩进set cindent "设置使用 C/C++ 语言的自动缩进方式set shiftwidth=4 "设置自动缩进 4 个空格set sts=4 "即设置 softtabstop 为 4. 输入 tab 后就跳了 4 格set tabstop=4 "实际的 tab 即为 4 个空格, 而不是缺省的 8 个set textwidth=0:cd C:\Users\jason\Desktop"定义CompileRun函数,用来调用编译和运行func CompileRun()exec "w"if &filetype == 'c'exec "!gcc % -g -o %<.exe"elseif &filetype == 'cpp'exec "!g++ % -g -o %<.exe"elseif &filetype == 'java'exec "!javac %"endifendfunc"结束定义ComplieRun"定义Run函数func Run()if &filetype == 'c' || &filetype == 'cpp'exec "!%<.exe"elseif &filetype == 'java'exec "!java %<"endifendfunc"定义Debug函数,用来调试程序func Debug()exec "w"if &filetype == 'c'exec "!gcc % -g -o %<.exe"exec "!gdb %<.exe"elseif &filetype == 'cpp'exec "!g++ % -g -o %<.exe"exec "!gdb %<.exe"elseif &filetype == 'java'exec "!javac %"exec "!jdb %<"endifendfunc"定义CompileAndRun函数,用来编译并运行程序func CompileAndRun()exec "w"if &filetype == 'c'exec "!gcc % -g -o %<.exe"exec "!%<.exe"elseif &filetype == 'cpp'exec "!g++ % -g -o %<.exe"exec "!%<.exe"elseif &filetype == 'java'exec "!javac %"exec "!java %<"endifendfunc"设置程序的运行和调试的快捷键F10和F11map <F9> :call CompileRun()<CR>map <F10> :call Run()<CR>map <F8> :call Debug()<CR>map <F11> :call CompileAndRun()<CR>