For me, because of laziness. I do not even want to read http://docs.sublimetext.info/en/latest/reference/symbols.html and write .tmPreferences
files for myself since CTags
is working.
The following things are what I ran into quite a long time ago and I re-tested them today after I saw this post.
Let’s say I create a ST project which has the following directory structure.
symbol_test/
├ app.php
└ define.php
In define.php
,
<?php
define('MY_CONSTANT', 'HELLO');
In app.php
,
<?php
include 'define.php';
echo MY_CONSTANT; // this prints: HELLO
Okay, that’s our environment. Now, let’s work on our project.
- close all tabs
- open
app.php
- Oh, what’s the value/definition of
MY_CONSTANT
?
- Press F12 and nothing happens.
- Press Ctrl+R and find nothing.
- Press Ctrl+Shift+R and find nothing.
- Try
CTags
, after tags are built, Ctrl+T, Ctrl+T and voila!
Let’s say I do not know there is a plugin named CTags. After reading the ST document, I write a simple .tmPreferences
for PHP as below.
In Symbol List - Constants.tmPreferences
,
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Symbols List: Constants</string>
<key>scope</key>
<string>constant.other.php, meta.string-contents.quoted.single.php</string>
<key>settings</key>
<dict>
<key>showInSymbolList</key>
<integer>1</integer>
<key>showInIndexedSymbolList</key>
<string>1</string>
</dict>
</dict>
</plist>
Okay, now F12 works for me, cheers!
But
- Should I maintain this
.tmPreference
for myself?
- There is no special scope for
MY_CONSTANT
in define('MY_CONSTANT', 'HELLO');
, using meta.string-contents.quoted.single.php
as the capture scope would inject quite lots of crap into your symbol list. Maybe I should report this to ST official?
I am not saying ST cannot do what CTags can do. But how much effort people want to put with a comparison to just install CTags? You just cannot expect everyone dig into the issue like this.
I think most of users do not know what happened. They just try F12 and let it go. Where is the doc? What should I do to fix this? How many cases are just like this and I have to write my own .tmPreference
? I do not care. Maybe just install CTags.
Actually, CTags is not omnipotent. I use both CTags and F12.