Ⅰ. 插件描述

Automatically discover and "properly" update ctags files on save

Ⅱ. 基本信息

创建日期:  2005-09-02
使用用户:  685
Github星:  230
插件作者:  Craig Emery

Ⅲ. 安装方法


Plugin 'craigemery/autotag'
… 然后在Vim中运行以下命令:
:source %

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。


NeoBundle 'craigemery/autotag'
… 然后在Vim中运行以下命令:
:source %


Plug 'craigemery/autotag'
… 然后在Vim中运行以下命令:
:source %


cd ~/.vim/bundle
git clone

Ⅳ. 文档说明


If you use ctags to make tags files of your source, it's nice to be able to re-run ctags on a source file when you save it.

However, using ctags -a will only change existing entries in a tags file or add new ones. It doesn't delete entries that no longer exist. Should you delete an entity from your source file that's represented by an entry in a tags file, that entry will remain after calling ctags -a.

This python function will do two things:

1) It will search for a tags file starting in the directory where your source file resides and moving up a directory at a time until it either finds one or runs out of directories to try.

2) Should it find a tags file, it will then delete all entries in said tags file referencing the source file you've just saved and then execute ctags -a on that source file using the relative path to the source file from the tags file.

This way, every time you save a file, your tags file will be seamlessly updated.


Currently I suggest you use Vundle and install as a normal Bundle

From the Vim command-line

:BundleInstall 'craigemery/vim-autotag'

And add to your ~/.vimrc

Bundle 'craigemery/vim-autotag'

Or you can manually install

git clone git://
cd ~/.vim/
mkdir -p plugin
cp ~/vim-autotag.git/plugin/autotag.vim plugin/

Install as a Pathogen bundle

git clone git:// ~/.vim/bundle/vim-autotag


Autotag can be configured using the following global variables:

g:autotagmaxTagsFileSizea cap on what size (in bytes) tag file to strip etc
g:autotagExcludeSuffixessuffixes to not ctags on
g:autotagVerbosityLevellogging verbosity (as in Python logging module)
g:autotagCtagsCmdname of ctags command
g:autotagTagsFilename of tags file to look for
g:autotagDisabledDisable autotag (enable by setting to any non-blank value)
g:autotagStopAtstop looking for a tags file (and make one) at this directory (defaults to $HOME)

These can be overridden with buffer specific ones. b: instead of g:

let g:autotagTagsFile=".tags"


Like autotag.vim? Follow the repository on
GitHub and vote for it on And if
you're feeling especially charitable, follow [craigemery] on


Copyright (c) Craig Emery. Distributed under the same terms as Vim itself.
See :help license.