Meet ctags – The Vim user's guide to tags, navigation and everything. – Tags?



Meet ctags – The Vim user's guide to tags, navigation and everything. – Tags?

0 0


vim-ctags-talk

Slides for the talk I gave at Vim London in April.

On Github Wolfy87 / vim-ctags-talk

Meet ctags

The Vim user's guide to tags, navigation and everything.

By Oliver Caldwell

Tags?

<div>

(sorry about the meta)

Retracing your steps

:tags

  • Previous - CTRL-T / :pop
  • Next - :tag
  • Push - CTRL-]

Multiple results?

:tnext + :tprevious

]t + [t with tpope/vim-unimpaired

So much more

Google: "vim wiki browsing programs with tags"

What's ctags then?

  • sudo apt-get install exuberant-ctags
  • brew install ctags

(pain may will vary between platforms)

My first tag file

ctags -Rf ./.tags --exclude=.git ./components
!_TAG_FILE_FORMAT	2	/extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED	1	/0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR	Darren Hiebert	/dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME	Exuberant Ctags	//
!_TAG_PROGRAM_URL	http://ctags.sourceforge.net	/official site/
!_TAG_PROGRAM_VERSION	5.9~svn20110310	//
0	./components/reveal.js/plugin/zoom-js/zoom.js	/^			magnify( scrollOffset.x, scrollOffset.y, 0, 0, 1 );$/;"	r
1	./components/reveal.js/js/reveal.js	/^		var event = document.createEvent( "HTMLEvents", 1, 2 );$/;"	r
190	./components/reveal.js/js/reveal.js	/^		if( isPaused() && [66,190,191].indexOf( event.keyCode ) === -1 ) {$/;"	r

Insert 500 lines or so of similar stuff...

zoomFactor	./components/reveal.js/plugin/print-pdf/print-pdf.js	/^page.zoomFactor = 1.5;$/;"	r
zoomLevel	./components/reveal.js/plugin/zoom-js/zoom.js	/^		zoomLevel: function() {$/;"	r

Make Vim use .tags

set tags+=.tags

Making it less awkward

command! GenerateTags call system('ctags -Rf ./.tags --exclude=.git ./components') | echo
nmap <F5> :GenerateTags<CR>

But wait, there's more!

  • --python-kinds=-i
  • `cat .srclist`
./assets/**/*.js
./**/*.py

Hello? Yes, this is command line

vim +GenerateTags +qa

Thanks!

Wolfy87/vim-ctags-talk

Wolfy87/vim-config

^[:qa!