Maintainer: | Cameron Eagans <me@cweagans.net> |
---|
UPDATE: Ctags is discussed at Google Plus. Kaushal Modi recommended three Emacs plugins: ctags-update; etags-table; etags-select; I tried them. My code has same features as ctags-update and etags-table. I prefer my own code because it's simpler and controllable. But I do like etags-select, it provides better UI for finding tag and I will use it. Jun 25, 2015 Luckily for us, Mac OS X comes with ctags installed by default but unfortunately for us, this version (despite what the documentation says) doesn’t support Objective-C. We’ll have to use Homebrew to install a newer version. Start by executing the following to install the latest and greatest version of ctags: $ brew install ctags -HEAD.
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.
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
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!![Ctags for macbook Ctags for macbook](https://www.qed42.com/sites/default/files/inline-images/Code.png)
From the command line
Use
vim -t
to open vim to a certain tag.Navigating through multiple definition
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 ) |
Key shortcuts
You can also place your cursor on some text and press
^]
to jump to that tag.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. Beechcraft bonanza f33a poh pdf printer. You can also check out my plugin, vim-fastunite, which offers a pre-packaged distribution of Unite.vim.
Futher reading
- Browsing programs with tags (vim.wikia.com)
Ctags Mac Os Install
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!).