" Vim with all enhancements
source $VIMRUNTIME/vimrc_example.vim
" Remap a few keys for Windows behavior
source $VIMRUNTIME/mswin.vim
" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
set diffexpr=MyDiff()
endif
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 arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
if &sh =~ '\ ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
set encoding=utf-8 "设置文件的代码形式 utf8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,chinese,cp936
set relativenumber
:inoremap ( ()i
:inoremap ) =ClosePair(')')
:inoremap { {}O
:inoremap } =ClosePair('}')
:inoremap [ []i
:inoremap ] =ClosePair(']')
:inoremap " ""i
:inoremap ' ''i
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\"
else
return a:char
endif
endfunction
set number
syntax on
set autoindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set smartindent
map ggVGY "映射全选 ctrl+A
vmap "+y "映射复制 ctrl+C
map "+gP "映射粘贴ctrl+V
set history=1000
set nobackup
set noswapfile
set noexpandtab
set noundofile
"Vim_plug
call plug#begin('~/vimfiles/plugged')
Plug 'scrooloose/nerdtree'
Plug 'tomasiser/vim-code-dark'
Plug 'vim-airline/vim-airline'
Plug 'morhetz/gruvbox'
Plug 'Yggdroot/indentLine'
Plug 'preservim/tagbar'
Plug 'vim-airline/vim-airline-themes'
Plug 'nanotech/jellybeans.vim'
"Plug 'valloric/youcompleteme'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
set laststatus=2 "永远显示状态栏
let g:airline_powerline_fonts = 1 " 支持 powerline 字体
let g:airline#extensions#tabline#enabled = 1
colorscheme retrobox
map :NERDTreeToggle
set guifont=Cascadia_Mono:h14
func! CompileGcc()
exec "w"
let compilecmd="!gcc "
let compileflag="-o %< "
if search("mpi\.h") != 0
let compilecmd = "!mpicc "
endif
if search("glut\.h") != 0
let compileflag .= " -lglut -lGLU -lGL "
endif
if search("cv\.h") != 0
let compileflag .= " -lcv -lhighgui -lcvaux "
endif
if search("omp\.h") != 0
let compileflag .= " -fopenmp "
endif
if search("math\.h") != 0
let compileflag .= " -lm "
endif
exec compilecmd." % ".compileflag
endfunc
func! CompileGpp()
exec "w"
let compilecmd="!clang++"
let compileflag="-o %<.exe "
if search("mpi\.h") != 0
let compilecmd = "!mpic++ "
endif
if search("glut\.h") != 0
let compileflag .= " -lglut -lGLU -lGL "
endif
if search("cv\.h") != 0
let compileflag .= " -lcv -lhighgui -lcvaux "
endif
if search("omp\.h") != 0
let compileflag .= " -fopenmp "
endif
if search("math\.h") != 0
let compileflag .= " -lm "
endif
exec compilecmd." % ".compileflag
endfunc
func! RunPython()
exec "!python %"
endfunc
func! CompileJava()
exec "!javac %"
endfunc
func! CompileCode()
exec "w"
if &filetype == "cpp"
exec "call CompileGpp()"
elseif &filetype == "c"
exec "call CompileGcc()"
elseif &filetype == "python"
exec "call RunPython()"
elseif &filetype == "java"
exec "call CompileJava()"
endif
endfunc
func! RunResult()
exec "w"
if search("mpi\.h") != 0
exec "!mpirun -np 4 ./%<"
elseif &filetype == "cpp"
exec "! %<"
elseif &filetype == "c"
exec "! %<"
elseif &filetype == "python"
exec "call RunPython"
elseif &filetype == "java"
exec "!java %<"
endif
endfunc
map :call CompileCode()
imap :call CompileCode()
vmap :call CompileCode()
map :call RunResult()
autocmd BufNewFile *.cpp 0r ~\vimfiles\template\a.cpp
nmap :TagbarToggle
nmap :bnext
"coc plugin
set hidden
set updatetime=100
inoremap pumvisible() ? coc#_select_confirm()
\: "\u\\=coc#on_enter()\"
"indentLine plugin
augroup VIMRC
au!
au BufWritePost .vimrc so %
augroup END