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. Ctags has a little downside when using Python: it recognizes import lines as a definition, at least as of ctags v5.8. No need to explain why it's annoying in most cases. After 2 years of suffering, I've found it's possible to overcome this simply by adding the -python-kinds=-i option to the command line, or better: to /.ctags. On your Mac, do one of the following: Remove tags from an item: Control-click the item or tap it with two fingers, then click Tags. Select the tags you want to remove, then press Delete. Remove tags from your Mac: In the Finder, choose Finder Preferences, then click Tags.
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.
Ctags Php
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
Wurth wow 5.00.8 keygen. 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
Exuberant Ctags Windows
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!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. 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)
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!).
Universal Ctags generates an index (or tag) file of language objects found in source files for many popular programming languages. This index makes it easy for text editors and other tools to locate the indexed items. Universal Ctags improves on traditional ctags because of its multilanguage support, its ability for the user to define new languages searched by regular expressions, and its ability to generate emacs-style TAGS files.
![Mac Mac](https://www.qed42.com/sites/default/files/inline-images/Code.png)
universal-ctags has the objective of continuing the development fromwhat existed in the Sourceforge area. Github exuberant-ctagsrepository was started by Reza Jelveh and was later moved to theuniversal-ctags organization.
The goal of the project is preparing and maintaining common/unified workingspace where people interested in making ctags better can worktogether.
Getting PACKCC compiler-compiler
Packcc is a compiler-compiler; it translates .peg grammar file to .cfile. packcc was originally written by Arihiro Yoshida. Its sourcerepository is at sourceforge. It seems that packcc at sourceforge isnot actively maintained. Some derived repositories are atgithub. Currently, our choice ishttps://github.com/enechaev/packcc. It is the most active one in thederived repositories.
The source tree of packcc is grafted at misc/packcc directory.Building packcc and ctags are integrated in the build-scripts ofUniversal-ctags.
The latest build and package
If you want to try the latest universal-ctags without building it yourself..
Windows
Daily builds are available at the ctags-win32 project.Go to the releases page to download zip packages.
Mac
See Homebrew Tap for Universal Ctags
Snap
Go to ctags-snap andclone the
ctags-snap
repo. Then, follow instructions to build thesnap package of ctags. Snapcraft will automatically fetch the sourcecode from GitHub.How to build and install
Gbc files. To build with Autotools, see
docs/autotools.rst
for more information.(To build on GNU/Linux, Autotools is your choice.)To build on Windows, see docs/windows.rst
for more information.To build on OSX, see docs/osx.rst
for more information.Manual
Man page (ctags.1) is generated only in Autotools based building process.In addition rst2man command is needed.
rst2man is part of the python-docutils package on Ubuntu.
Differences
Ctags Mac Os Install
You may be interested in how universal-ctags is different fromexuberant-ctags. The critical and attractive changes are explainedin docs/*.rst. The preformatted version is available on line,https://docs.ctags.io/.
The most significant incompatible changes:
Ctags For Mac Pro
- Universal-ctags doesn't load
~/.ctags
and./.ctags
at starting up time. Instead, it loads~/.ctags.d/*.ctags
and./.ctags.d/*.ctags
. See the above website and man pages(man/ctags.1.rst.in and man/ctags-incompatibilities.7.in in thesource tree). - Universal-ctags is more strict about characters that can beused in kind letters and kind names than Exuberant-ctags.
- The letter must be an alphabetical character (
[a-zA-EG-Z]
).F
is reserved forfile
kind. - The first character of the name must be alphabetic, andthe rest characters must be alphanumeric (
[a-zA-Z][a-zA-Z0-9]*
).
See the web site and man pages. The detailed background is explainedin #1737.If you want to reuse your .ctags written for Exuberant-ctags,you must review kind letters and names defined with--regex-<LANG>=..
options. When updating the definitions, using--kind-<LANG>
optionis appreciated.
Pull-requests are welcome!