Skip to content

Instantly share code, notes, and snippets.

@Flolagale
Last active May 25, 2020 00:25
Show Gist options
  • Save Flolagale/5195934 to your computer and use it in GitHub Desktop.
Save Flolagale/5195934 to your computer and use it in GitHub Desktop.
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()
@huowa222
Copy link

line 18:
Traceback (most recent call last):
File "", line 5, in no
OSError: [Errno 2] No such file or directory: 'tags'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment