j" 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 number
set relativenumber
set guifont=Hack_Nerd_Font_Mono:h12
set autoindent
set smartindent
set cindent
set tabstop=4
set shiftwidth=4
set clipboard=unnamed
set encoding=utf-8
set noswapfile
set nobackup
set noundofile
set cursorline
inoremap { {}<Left>
inoremap {<CR> {<CR>}<Esc>O
inoremap {{ {
inoremap {} {}
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endfunction
func! Run()
exec "w"
exec "!g++ -O2 -std=gnu++20 -Wall -Wextra -Wfatal-errors -o %<.exe %"
endfunc
func! St()
exec ":!%<.exe"
endfunc
map <F3> :bnext<CR>
map <F4> :w<CR>
map <F2> :Explore<CR>
map <F9> :call Run()<CR>
map <F11> :!%< <
map <F6> :CocRestart<CR>
map <F8> :bd<CR>
map <F5> :IndentLinesToggle<CR>
inoremap <F10> #include <algorithm><CR>#include <iostream><CR>#include <cstring><CR>#include <cmath><CR><CR>typedef long long ll;<CR>typedef long double ld;<CR>typedef unsigned long long ull;<CR><CR>using namespace std;<CR><CR>const int INF = 0x3f3f3f3f;<CR><CR><CR>int main()<CR>{<CR>ios::sync_with_stdio(0);<CR>cin.tie(0);<CR><CR><CR><CR>return 0;<CR><ESC>i}<CR><ESC>i
call plug#begin('~/vimfiles/plugged')
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 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'christoomey/vim-tmux-navigator'
Plug 'tomasiser/vim-code-dark'
Plug 'letorbi/vim-colors-modern-borland'
Plug 'jacoborus/tender.vim'
Plug 'sainnhe/gruvbox-material'
Plug 'joshdick/onedark.vim'
Plug 'altercation/vim-colors-solarized'
Plug 'crusoexia/vim-monokai'
call plug#end()
set background=dark
colorscheme onedark
set laststatus=2 "永远显示状态栏
let g:airline_powerline_fonts = 1 " 支持 powerline 字体
let g:airline#extensions#tabline#enabled = 1
augroup VIMRC
au!
au BufWritePost .vimrc so %
augroup END
set hidden
set updatetime=100
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
"----缩进指示线 indentLine 配置 ----------
let g:indentLine_enabled = 1
let g:indentLine_char='┆'
set guifont=Hack\ Nerd\ Font\ Mono\ Italic:h12