Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate ctags incrementally in vim. Juste paste this into your .vimrc.
function! GenerateTagsIncrementally()
python << EOF
import os
print('Generating tags incrementally.')
# Walk the file tree, if a file has an mtime more recent than the tag file,
# add it to the list of files to index.
tags_mtime = os.stat('tags').st_mtime
with open('list', 'w') as fp:
for dirpath, dirnames, filenames in os.walk(os.getcwd()):
for filename in filenames:
full_path = os.path.join(dirpath, filename)
if os.stat(full_path).st_mtime > tags_mtime:
fp.write(full_path + '\n')
# print(full_path) # Files to be indexed.
# Run ctags using the created list of files.
os.system('ctags --recurse --verbose --append --extra=+q --fields=+aimS --c-kinds=+p --c++-kinds=+p -L list')
os.remove('list')
EOF
endfunction
command GenerateTagsIncrementally call GenerateTagsIncrementally()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.