Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " 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 =~ '\<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
- let cmd = substitute(cmd, '!', '\!', 'g')
- silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . 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 ( ()<ESC>i
- :inoremap ) <c-r>=ClosePair(')')<CR>
- :inoremap { {<CR>}<ESC>O
- :inoremap } <c-r>=ClosePair('}')<CR>
- :inoremap [ []<ESC>i
- :inoremap ] <c-r>=ClosePair(']')<CR>
- :inoremap " ""<ESC>i
- :inoremap ' ''<ESC>i
- function! ClosePair(char)
- if getline('.')[col('.') - 1] == a:char
- return "\<Right>"
- else
- return a:char
- endif
- endfunction
- set number
- syntax on
- set autoindent
- set tabstop=4
- set softtabstop=4
- set shiftwidth=4
- set smartindent
- map <C-A> ggVGY "映射全选 ctrl+A
- vmap <C-C> "+y "映射复制 ctrl+C
- map <C-V> "+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 <F2> :NERDTreeToggle<CR>
- 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 <F5> :call CompileCode()<CR>
- imap <F5> <ESC>:call CompileCode()<CR>
- vmap <F5> <ESC>:call CompileCode()<CR>
- map <F6> :call RunResult()<CR>
- autocmd BufNewFile *.cpp 0r ~\vimfiles\template\a.cpp
- nmap <F8> :TagbarToggle<CR>
- nmap <F3> :bnext<CR>
- "coc plugin
- set hidden
- set updatetime=100
- inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
- \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
- "indentLine plugin
- augroup VIMRC
- au!
- au BufWritePost .vimrc so %
- augroup END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement