Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set modelines=0 " CVE-2007-2438
- " Normally we use vim-extensions. If you want true vi-compatibility
- " remove change the following statements
- set nocompatible " Use Vim defaults instead of 100% vi compatibility
- set backspace=2 " more powerful backspacing
- " Don't write backup file if vim is being called by "crontab -e"
- au BufWrite /private/tmp/crontab.* set nowritebackup nobackup
- " Don't write backup file if vim is being called by "chpass"
- au BufWrite /private/etc/pw.* set nowritebackup nobackup
- let skip_defaults_vim=1
- :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
- set guifont=Monaco:h12
- if has("autocmd")
- au VimEnter,InsertLeave * silent execute '!echo -ne "\e[2 q"' | redraw!
- au InsertEnter,InsertChange *
- \ if v:insertmode == 'i' |
- \ silent execute '!echo -ne "\e[6 q"' | redraw! |
- \ elseif v:insertmode == 'r' |
- \ silent execute '!echo -ne "\e[4 q"' | redraw! |
- \ endif
- au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!
- endif
- set mouse=a
- 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++ -O2 -Wall -Wextra"
- let compileflag="-o %<"
- 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>
- call plug#begin()
- Plug 'preservim/nerdtree'
- Plug 'tomasiser/vim-code-dark'
- Plug 'vim-airline/vim-airline'
- Plug 'majutsushi/tagbar'
- Plug 'mhinz/vim-startify'
- Plug 'vim-airline/vim-airline-themes'
- Plug 'neoclide/coc.nvim', {'branch': 'release'}
- Plug 'neoclide/coc-java'
- Plug 'yggdroot/indentline'
- call plug#end()
- set laststatus=2
- "let g:airline_powerline_fonts = 1
- let g:airline#extensions#tabline#enabled = 1
- colorscheme retrobox
- map <silent> <F2> :NERDTreeToggle<CR>
- autocmd BufNewFile *.cpp 0r ~/a.cpp
- nmap <F8> :TagbarToggle<CR>
- nmap <F3> :bnext<CR>
- "indent line plugin
- let g:indentLine_setConceal = 0
- let g:indentLine_setColors = 1
- let g:indentLine_char_list = ['|', '¦', '┆', '┊']
- "COC extensions
- set hidden
- set updatetime=300
- nmap <silent> [g <Plug>(coc-diagnostic-prev)
- nmap <silent> ]g <Plug>(coc-diagnostic-next)
- nmap <silent> gd <Plug>(coc-definition)
- nmap <silent> gy <Plug>(coc-type-definition)
- nmap <silent> gi <Plug>(coc-implementation)
- nmap <silent> gr <Plug>(coc-references)
- inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
- \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
- augroup VIMRC
- au!
- au BufWritePost .vimrc so %
- augroup END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement