Maintainer: | Cameron Eagans <me@cweagans.net> |
---|
Best (Open Source Tagging for Mac OS X) implementation ever! I use also Leap, by far the best standalone OpenMeta solution, but Tags is perfectly integrated in Mac OS X. Even tagging in Mail is a charm. And, after some Mails with the Developer and testing some special Debug-Versions, Tags works also in Lion (10.7.2). $ alias ctags='`brew -prefix`/bin/ctags' When you’re sitting in the directory you want to index, just run: ctags -R. Ctags will walk through the directory recursively, tagging all source files it encounters. For very large projects, this might take a while, but normally it’s pretty fast. See ctags-incompatibilities(7) about known incompatible changes with Exuberant-ctags. See ctags-client-tools(7) if you are interested in writing a tool for processing tags files. See ctags-lang-python(7) about python input specific notes. See readtags(1) about a client tool for. With ctags, you can use autocomplete (aka omnicomplete) for function and variable names as you type, something cscope doesn’t give you. Also, there’s much less setup to get ctags up and running as it’s generally already installed. The downside is ctags doesn’t do as well as cscope with a conglomerated or mostly unknown codebase.
This part of the documentation is written by Cameron Eagans, a co-maintainer of Universal-ctags and the maintainer ofthe OSX packaging of this project.
Build Prerequisites¶
Building ctags on OSX should be no different than building on GNU/Linux. The same toolchains are used, and the Mac OSpackaging scripts use autotools and make (as you’d expect).
You may need to install the xcode command line tools. You can install the entire xcode distribution from the App Store,or for a lighter install, you can simply run
xcode-select--install
to only install the compilers and such. Seehttps://stackoverflow.com/a/9329325 for more information. Once your build toolchain is installed, proceed to the nextsection.At this point, if you’d like to build from an IDE, you’ll have to figure it out. Building ctags is a pretty straightforwardprocess that matches many other projects and most decent IDEs should be able to handle it.
Building Manually (i.e. for development)¶
You can simply run the build instructions in README.md.
Building with Homebrew¶
Homebrew (https://brew.sh/) is the preferred method for installing Universal-ctags for end users. Currently, the processfor installing with Homebrew looks like this:
Eventually, we hope to move the Universal-ctags formula to the main Homebrew repository, but since we don’t have anytagged releases at this point, it’s a head-only formula and wouldn’t be accepted. When we have a tagged release, we’llsubmit a PR to Homebrew.
If you’d like to help with the Homebrew formula, you can find the repository here:https://github.com/universal-ctags/homebrew-universal-ctags
Differences between OSX and GNU/Linux¶
There other things where building ctags on OSX differs from building on GNU/Linux.
- Filenames on HFS+ (the Mac OS filesystem) are case-preserving, but not case-sensitive in 99% of configurations. If auser manually formats their disk with a case sensitive version of HFS+, then the filesystem will behave like normalGNU/Linux systems. Depending on users doing this is not a good thing.
![Ctags for macbook Ctags for macbook](https://image.slidesharecdn.com/vimctagspublic-140523001735-phpapp02/95/vimctags-6-638.jpg?cb=1400804374)
Contributing¶
This documentation is very much a work in progress. If you’d like to contribute, submit a PR and mention @cweagans forreview.
Today I learned
Ctags is not always the best solution to this today. There are Language Server implementations for some modern languages that would offer these features and more. Also, as of 2019, there are other ctags alternatives to consider today, such as Universal Ctags.
Ctags lets you navigate code fast, and is perhaps the single most useful productivity boosting tool in any developer's arsenal. If you're not using Ctags yet, let's get you started.
What's it for?
Ctags indexes a project's tags, or names of its classes and methods. Coupled with some integration with your editor (shown: Vim's unite-tag), it will give you two interesting features to help you traverse code base:
Installing Ctags
Exuberant Ctags
In OS X, use Homebrew to install Exuberant Ctags. This is a more useful version of ctags than the one that ships with Xcode.
Ctags options
Let's make ctags ignore some common directories. Save this file as
~/.ctags
.Generate ctags for a project
Go to your project's path, and run ctags to generate a
tags
file in your project. This is the index of all tags in your project that your editor will use.Ignore all ctags files
It's safe to make all projects ignore all files called
tags
. I recommend setting up a global git ignore list.Vim setup
Auto-update ctags files
Use vim-autotag to automatically update
tags
files. This will only work on projects that have already had ctags -R
performed before.Jumping to tags
Vim Ctags Plugin
Use
:tag
to go to the definition of a certain tag. Usually, you will want to use this to jump to a certain Class or Method. Yes, this supports tab completion!From the command line
Use
vim -t
to open vim to a certain tag.Navigating through multiple definition
Cisco anyconnect secure mobility client mac yosemite download free. If you used
:tag
on a tag that's got multiple definitions, use these commands to sift through them all.Shortcut | Definition |
---|---|
:tn | Move to next definition (:tnext ) |
:tp | Move to previous definition (:tprevious ) |
:ts | List all definitions (:tselect ) |
Gtags Github
Key shortcuts
You can also place your cursor on some text and press
^]
to jump to that tag.Ctags Php
Shortcut | Definition |
---|---|
^] | Jump to definition |
^t | Jump back from definition |
^W } | Preview definition |
g] | See all definitions |
Unite integration
If you're using unite.vim, you can use unite-tag to browse tags. You can also check out my plugin, vim-fastunite, which offers a pre-packaged distribution of Unite.vim. Mindmaster crack.
Futher reading
- Browsing programs with tags (vim.wikia.com)
You have just read Navigate code like a pro with Ctags, written on April 22, 2015. This is Today I Learned, a collection of random tidbits I've learned through my day-to-day web development work. I'm Rico Sta. Cruz, @rstacruz on GitHub (and Twitter!).