This Sublime Text 2 Package provides support for working with tags generated by Exuberant CTags
The ctags command is searched for on PATH. It works by doing a binary search of an mmap()'d `tags` file so it will work efficiently with very large ( 50MB+ etc ) tags files if needed.
This is only designed to work with Exuberant CTags
If anyone is having trouble getting the CTags -R flag to work on OSX, you are probably using the stock CTags installation.
- Follow the instructions on http://adamyoung.net/Exuberant-Ctags-OS-X to install a good version of CTags that recognizes the -R flag. This installs CTags to /usr/local/bin.
Note: There is a broken link on that page - looks like it was an old sourceforge mirror. Here's a working link: http://ignum.dl.sourceforge.net/project/ctags/ctags/5.8/ctags-5.8.tar.gz
- Make sure that Sublime Text is using the right version of CTags: Ensure that /.MacOSX/environment.plist has /usr/local/bin in the PATH string before /usr/bin (the standard location for CTags). Here's a sample environment.plist that should work:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>PATH</key> <string>/usr/local/bin:/usr/bin:/bin</string> </dict> </plist>
- If /usr/local/bin wasn't in your PATH already, you have to log out and log back in for the environment variables to be read in again.
- No dependencies!
If you are a git user, the best way to install the package and keep up to date is to clone the repo directly into your /Packages directory in the Sublime Text 2 application settings area.
Go to your Sublime Text 2 `Packages` directory and clone the repository using the command below:
$ git clone https://github.com/SublimeText/CTags CTags
- Download the files using the .zip download option
- Unzip the files (and rename the folder to CTags if needed)
- Copy the folder to your Sublime Text 2 Packages directory
See this forum thread for a bit of background.
This uses `tags` files created in `ctags -R` recursive mode.
The commands will try and find a `tags` file in the same directory as the current view, walking up directories until it finds one. If it can't find one it will offer to build some ( in the directory of the current view ) (TODO: doesn't ask as missing api from S1)
If a symbol can't be found in a tags file it will search in alternative locations.
If you create a file `tags_search_paths` in the same folder as your `tags` file, listing alternative locations (full absolute paths, one per line) it will search those files also.
eg
D:\myProject\tags
There's a CTags.sublime-settings file:
{ "debug" : false, "ctags_command" : "ctags -R", "filters" : {"source.python": {"type":"^i$"}}, "extra_tag_paths" : [ [["source.python", "windows"], "C:\\Python27\\Lib\\tags"]] }
`filters` will allow you to set scope specific filters against a field of the tag. In the excerpt above, imports tags like "from a import b" are filtered.
'(?P<symbol>[^\t]+)\t' '(?P<filename>[^\t]+)\t' '(?P<ex_command>.*?);"\t' '(?P<type>[^\t\r\n]+)' '(?:\t(?P<fields>.*))?'
`extra_tag_paths` is a list of extra places to look for keyed by (selector, platform)
Note the platform (`windows` in the example above) is tested against `sublime.platform()` so any values that function returns are valid.
The rest of the options are fairly self explanatory.
If there are any problems or you have a suggestion open an issue and I will receive an email notification.
Thanks :)
Command | Key Binding |
---|---|
rebuild_ctags | ctrl+alt+shift+t |
navigate_to_definition | ctrl+rightbracket |
jump_back | ctrl+leftbracket |
jump_back to_last_modification | ctrl+shift+leftbracket |
show_symbols | alt+s |
show_symbols multi | alt+shift+s |