Ctags in Atom on OSX

26 February 2016   0 comments   Web development, MacOSX

Mind that age!

This blog post is 4 years old! Most likely, its content is outdated. Especially if it's technical.

Symbols View setting page
In Atom , by default there's a package called symbols-view. It basically allows you to search for particular functions, classes, variables etc. Most often not by typing but by search based on whatever word the cursor is currently on.

With this all installed and set up I can now press Cmd-alt-Down and it automatically jumps to the definition of that thing. If the result is ambiguous (e.g. two functions called get_user_profile) it'll throw up the usual search dialog at the top.

To have this set up you need to use something called ctags. It's a command line tool.

This Stack Overflow post helped tremendously. The ctags I had installed was something else (presumably put there by installing emacs). So I did:

$ brew install ctags

And then added

alias ctags="`brew --prefix`/bin/ctags"

...in my ~/.bash_profile

Now I can run ctags -R . and it generates a binary'ish file called tags in the project root.

However, the index of symbols in a project greatly varies with different branches. So I need a different tags file for each branch. How to do that? By hihjacking the .git/hooks/post-checkout hook.

Now, this is where things get interesting. Every project has "junk". Stuff you have in your project that isn't files you're likely to edit. So you'll need to list those one by one. Anyway, here's what my post-checkout looks like:


set -x

ctags -R \
  --exclude=build \
  --exclude=.git \
  --exclude=webapp-django/static \
  --exclude=webapp-django/node_modules \

This'll be run every time I check out a branch, e.g. git checkout master.


Your email will never ever be published

Related posts

Whatsdeployed on only one site 26 February 2016
Web performance optimization's dark side 16 March 2016
Related by Keyword:
Mozilla Symbol Server (aka. Tecken) load testing 06 September 2017
Best Atom packages of 2015 22 January 2016
How do log ALL PostgreSQL SQL happening 20 July 2015
Migration of Postgres 9.2 to 9.3 with Homebrew and json_enhancements 30 April 2014
WSSE Authentication and Apache 13 December 2007