[奇怪的东西]我的.vimrc
储存一下,顺便当储存记录语法
inoremap ( <c-r>=AutoBracket('(')<CR>
inoremap [ <c-r>=AutoBracket('[')<CR>
inoremap { <c-r>=AutoBracket('{')<CR>
inoremap " <c-r>=AutoBracket('"')<CR>
inoremap ' <c-r>=AutoBracket("'")<CR>
function AutoBracket(ch)
if getline('.')[col('.') - 1] == "'"
return a:ch
else
if a:ch == '('
return "()\<LEFT>"
elseif a:ch == '['
return "[]\<LEFT>"
elseif a:ch == '{'
return "{}\<LEFT>"
elseif a:ch == '"'
return "\"\"\<LEFT>"
elseif a:ch == "'"
return "''\<LEFT>"
endif
endfunction
inoremap <BS> <c-r>=PurgeBracket()<CR>
function PurgeBracket()
if getline('.')[col('.') - 2] == '(' && getline('.')[col('.') - 1] == ')'
return "\<RIGHT>\<BS>\<BS>"
elseif getline('.')[col('.') - 2] == '[' && getline('.')[col('.') - 1] == ']'
return "\<RIGHT>\<BS>\<BS>"
elseif getline('.')[col('.') - 2] == '"' && getline('.')[col('.') - 1] == '"'
return "\<RIGHT>\<BS>\<BS>"
elseif getline('.')[col('.') - 2] == '{' && getline('.')[col('.') - 1] == '}'
return "\<RIGHT>\<BS>\<BS>"
elseif getline('.')[col('.') - 2] == "'" && getline('.')[col('.') - 1] == "'"
return "\<RIGHT>\<BS>\<BS>"
else
return "\<BS>"
endif
endfunction
set number
set cindent
set autoindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
set noexpandtab
set mouse=a
set foldenable
set foldmethod=manual
nnoremap <F5> :call SaveAndCompile()<CR>
function SaveAndCompile()
exec(":w")
exec("!g++ -g -std=c++11 -Wall -Wconversion -Wshadow % -o %<")
endfunction
nnoremap <F6> :call CompileAndRun()<CR>
function CompileAndRun()
exec(":w")
exec("!g++ -g -std=c++11 -Wall -Wconversion -Wshadow % -o %<")
exec("!time ./%<")
endfunction
inoremap <CR> <c-r>=BraceAutoNewline()<CR>
function BraceAutoNewline()
if getline('.')[col('.') - 2] == '{' && getline('.')[col('.') - 1] == '}'
return "\<CR>\<ESC>O"
else
return "\<CR>"
endif
endfunction