1. 程式人生 > 實用技巧 >習題:Treeland Tour(樹DP)

習題:Treeland Tour(樹DP)

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 
"共享剪貼簿  
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"
	exec "!g++ % -o %< && ./%<"
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對映為把程式碼搞出來