Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh taglist in vim?

Tags:

vim

When I make a change to a file, for example, add a function, how can I make the taglist automatically update the "tag list" in its windows after I save the change?

like image 661
Haiyuan Zhang Avatar asked Jan 07 '10 10:01

Haiyuan Zhang


People also ask

How to use taglist in Vim?

To open the selected file in a tab, use the 't' key. If the file is already present in a tab then the cursor is moved to that tab otherwise the file is opened in a new tab. To jump to a tag in a new tab press Ctrl-t. The taglist window is automatically opened in the newly created tab.

How do I enable tags in Vim?

Using a Specific Tags File To use the tags file, you'll need to open Vim and tell it where it is. Still in the Vim source directory, I ran vim and then typed :set tags+=tags to tell it to use the ./tags file. At this point, Vim knows about the tags file — you don't need to tell it to load the file.

What is Ctags Vim?

Ctags is a tool that generates a tag file of names found in source files. In Moodle, it can be used to index PHP functions, variables, classes and so on. These tags allow definitions to be quickly and easily located by a text editor such as vim.


1 Answers

I adapted my setup from the C++ code completion vim tip.

map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>

When needed, I press Ctrl-F12 to regenerate tags.

If you're using vim-taglist, you could add to your .vimrc an autocommand for the BufWritePost event to update the taglist window after every save:

autocmd BufWritePost *.cpp :TlistUpdate
like image 152
Greg Bacon Avatar answered Oct 07 '22 00:10

Greg Bacon