public
Last active

My Vim ctags configuration

  • Download Gist
ctags_autocmd.vim
VimL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
function! DelTagOfFile(file)
let fullpath = a:file
let cwd = getcwd()
let tagfilename = cwd . "/tags"
let f = substitute(fullpath, cwd . "/", "", "")
let f = escape(f, './')
let cmd = 'sed -i "/' . f . '/d" "' . tagfilename . '"'
let resp = system(cmd)
endfunction
 
function! UpdateTags()
let f = expand("%:p")
let cwd = getcwd()
let tagfilename = cwd . "/tags"
 
if filereadable(tagfilename)
let cmd = 'ctags -a -f ' . tagfilename . ' "' . f . '"'
call DelTagOfFile(f)
let resp = system(cmd)
endif
endfunction
 
autocmd BufWritePost * call UpdateTags()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.