I have multiple git repositories. Also I use Vim as my editor especially for C and C++ code.
ctags a great tool to generate cross reference tags file. Vim support tags file to jump around between different source code files. Vim require to set tags variable to the path of tags file generated by ctags. Since I work on multiple git repositories, having a static tags file in .vimrc file is not an option for me. So I came up with .vimrc script to set the tags file.
let s:top_level_cmd = "git rev-parse --show-toplevel" let s:top_level_dir = system(s:top_level_cmd) if !v:shell_error let s:tag_file = substitute(system(s:top_level_cmd), "\n", "", "g"). '/tags' execute 'set tags='. s:tag_file endif