vim配置文件

set nocompatible
"好像能少点bug
set nu
"显示行数
set cursorline
"突出显示当前行
set tabstop=4
"缩进为4个空格
set sw=4
"自动缩进为4个空格
set autoindent
"自动缩进
set cindent
"c语言格式缩进
set mouse=a
"可以使用鼠标
set ls=2
"状态栏
set nobackup
set noswapfile
"禁止生成临时文件
set clipboard+=unnamed 
"共享剪贴板  
set t_Co=256
color ron
"主题
: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
"自动补全
map <F5> :call Run()<CR>
func Run()
	exec "w"
	if &filetype=='cpp' 
		exec "!g++ % -o %< && ./%<"
	elseif &filetype=='c'
		exec "!gcc % -o %< && ./%<"
	else
		exec "!python3 %"
	endif
endf
"F5映射为编译并运行文件
map <F8> :call Gdb()<CR>
func Gdb()
	exec "w"
	exec "!g++ % -o %< -g && gdb %< -q"
endf 
"F8映射为编译并用gdb调试文件
map <F9> :call Get()<CR>
func Get()
	exec "w"
	exec "!cat %"
endf
"F9映射为把代码搞出来
map <F6> :call Bao()<CR>
func Bao()
	exec "w"
endf
"F6映射为保存
posted @ 2020-07-31 20:29  liuchanglc  阅读(397)  评论(1编辑  收藏  举报