$ brew tap universal-ctags/universal-ctags$ brew install --HEAD universal-ctags$ alias ctags=“`brew —-prefix`/bin/ctags”
Using tags is a powerful tool to be able to jump to the definition of a function, variable, or class in Vim. Install universal-ctags and alias it as ctags. This allows adding support for languages that are not supported out of the box by universal-ctags (such as golang).
Add the following lines to your .ctags file to support golang:
--langdef=golang
--langmap=golang:.go
--regex-golang=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/f,func/
--regex-golang=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/v,var/
Now you can generate tags for source files:
$ ctags -R .
Open up a file in vim and use Ctrl + ] to jump to the definition of whatever is on your cursor and Ctrl + t to go back.
:help ctags # for more information and tips
Supported ctags languages http://ctags.sourceforge.net/languages.html