set nocompatible
"source $VIMRUNTIME/vimrc_example.vim
"source $VIMRUNTIME/mswin.vim
"source $VIMRUNTIME/gvimrc_example.vim
"if version > 603
set helplang=cn
"endif
if !exists("syntax_on")
syntax on
endif
" 设置跳格距离
set tabstop=4
" *****************************
set showmatch
set matchtime=1
set makeprg=g++\ -g\ %
" 设置自动缩进格数
set shiftwidth=4
" 打开自动缩进功能
set autoindent
"设置语法高亮风格
"设置退格键为普通模式
set backspace=2
"设定自动换行
set wrap
"设置括号匹配
"set sm
" 断行设置
set lbr " 不在单词中间断行
set fo+=mB " 打开断行模式对双字节语言的支持
" 文件浏览器
let g:winManagerWindowLayout = "FileExplorer"
" 把list的窗口放在右边,免得和文件浏览器冲突
let Tlist_Use_Right_Window=1
let &termencoding = &encoding
"set encoding=utf-8
set fileencodings=gbk,gb2312,utf-8,ucs-bom,cp936
"----------------below for txt file
augroup filetypedetect
au BufNewFile,BufRead *.* setf ztxt
augroup END
"au BufWinLeave *.txt mkview
"au BufWinEnter *.txt silent loadview
"colorscheme InkPot
set nu
filetype on
let Tlist_Ctags_Cmd = 'd:\ctags\ctags.exe'
set guifont=新宋体:h10:cGB2312
au BufWritePost * filet detect
"behave mswin
set 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 &sh =~ '\<cmd'
silent execute '!""C:\Program Files\Vim\vim63\diff" ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . '"'
else
silent execute '!C:\Program" Files\Vim\vim63\diff" ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
endif
endfunction
" 映射F5为make
noremap <silent> <F3> "+y
inoremap <silent> <F2> :<Esc>ggVG<CR>
noremap <silent> <F2> :<Esc>ggVG<CR>
noremap <silent> <F4> ::w<CR>
inoremap <silent> <F4> <Esc>:w<CR>
noremap <silent> <F5> ::make<CR>
noremap <silent> <F6> ::!a.exe<CR>
"noremap <silent> <F11> ::
" 映射F8使用Tlist
nnoremap <silent> <F8> :Tlist<CR>
" 映射F7调用文件浏览器
nnoremap <silent> <F7> :WMToggle<CR>
if has("autocmd")
" 自动检测文件类型并加载相应的设置
filetype plugin indent on
" Python 文件的一般设置,比如不要 tab 等
autocmd FileType python setlocal et | setlocal sta | setlocal sw=4
" Python Unittest 的一些设置
" 可以让我们在编写 Python 代码及 unittest 测试时不需要离开 vim
" 键入 :make 或者点击 gvim 工具条上的 make 按钮就自动执行测试用例
autocmd FileType python compiler pyunit
" autocmd FileType python setlocal makeprg=python\ D:\Downloads\Programs\gVim\vim\skeleton\alltests.py
autocmd FileType python setlocal makeprg=python\ %
autocmd BufNewFile,BufRead test*.py setlocal makeprg=python\ %
" 自动使用新文件模板
autocmd BufNewFile test*.py 0r D:\Downloads\Programs\gVim\vim\skeleton\test.py
autocmd BufNewFile alltests.py 0r D:\Downloads\Programs\gVim\vim\skeleton\alltests.py
autocmd BufNewFile *.py 0r D:\Downloads\Programs\gVim\vim\skeleton\skeleton.py
autocmd BufNewFile *.build 0r $HOME\template.build
autocmd BufNewFile *.cs 0r $HOME\template.cs
endif
"
"augroup c_prog
" au!
" fun! CFold()
" set foldmethod=syntax
" syntax region functionFold start="\(^\({\|\S.*{\)$\n\)\@<=\_[^}]" end="\(^{.*\)\@<!$\n\(^}\)\@=" transparent fold
" syntax region commentFold start="/\*" end="\*/" transparent fold keepend
" syntax region commentFold2 start="^\(^//.*$\n\)\@<!//.*\(\n//\)\@=$" end="^\(^//.*$\n\)\@<=//.*\(\n//\)\@!$" transparent fold keepend
" endfun
" autocmd FileType cs,cpp,c call CFold()
"augroup END
"
augroup python_prog
au!
fun! Python_fold()
execute 'syntax clear pythonStatement'
execute 'syntax keyword pythonStatement break continue del'
execute 'syntax keyword pythonStatement except exec finally'
execute 'syntax keyword pythonStatement pass print raise'
execute 'syntax keyword pythonStatement return try'
execute 'syntax keyword pythonStatement global assert'
execute 'syntax keyword pythonStatement lambda yield'
execute 'syntax match pythonStatement /\<def\>/ nextgroup=pythonFunction skipwhite'
execute 'syntax match pythonStatement /\<class\>/ nextgroup=pythonFunction skipwhite'
execute 'syntax region pythonFold start="^\z(\s*\)\%(.*:\s*\%(#.*$\)\?\)" end="^\%(\n*\z1\s\)\@!" transparent fold'
execute 'syntax sync minlines=2000 maxlines=4000'
set autoindent
set foldmethod=syntax
" set foldopen=all foldclose=all
set foldtext=substitute(getline(v:foldstart),'\\t','\ \ \ \ ','g').'\ \ ('.(v:foldend-v:foldstart+1).'\ lines)'
set fillchars=vert:\|,fold:\
set tabstop=4 shiftwidth=4 "nowrap
endfun
autocmd FileType python call Python_fold()
augroup END