Skip to content

Instantly share code, notes, and snippets.

@rafeco
Last active July 18, 2019 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rafeco/4462217 to your computer and use it in GitHub Desktop.
Save rafeco/4462217 to your computer and use it in GitHub Desktop.
My Vim ctags configuration
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment