"toggle number display
map <leader>tn :call Toggle_Number()<cr>
function! Toggle_Number()
if !exists("b:togglenum")
let b:togglenum=1
endif
if b:togglenum==1
execute "set nonu"
let b:togglenum=0
else
let b:togglenum=1
execute "set nu"
endif
endfunction
"auto add tags from project rootau BufReadPost,BufNewFile * call Add_Tags()
function! Add_Tags()
if expand("%:p:h") !=getcwd()
echohl WarningMsg | echo "Fail to make! This file is not in the current dir! Press <F7> to redirect to the dir of this file." | echohl None
return
endif
let srcdir=expand("%:p:h")
let i=0
while isdirectory(srcdir)
if i>3
break
endif
if filereadable(srcdir . "/tags")
let file=srcdir."/tags"
"echo printf("set tags %s", file)
if i==0
execute "set tags=".file
else
execute "set tags+=".file
endif
endif
let newdir=fnamemodify(srcdir,":p:h:h")
"echo printf("newdir %s", newdir)
if newdir != srcdir
let srcdir=newdir
else
break
endif
let i=i+1
endwhile
endfunction