The contents of the symbol list is controlled by a preferences file that tells sublime what scopes should appear in the symbol list for any given language and, optionally, what transformations should be done for display purposes (e.g. to indent the methods in a class).
Such configuration files are tmPreferences
files (XML files in Plist format) within a package and which are generally named with names that start with Symbol List
. For example, Packages/C++/Symbol List.tmPreferences
is one of such files for use in the C++ package (which covers, C, C++ and both flavors of Objective-C). Since the files are Plist files the actual names don’t matter, but this is a convention that makes such files easier to find.
There is some documentation on symbols you can read for more information.
Trivially, if you save the following XML into Packages/C++/Symbol List Pragma.tmPreferences
it will add all of the #pragma MARK
lines in your source files to the symbol list (current file only), replacing #pragma MARK
with " ---- "
:
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Symbol List</string>
<key>scope</key>
<string>(source.c | source.c++ | source.objc | source.objc++) & (meta.preprocessor.c)</string>
<key>settings</key>
<dict>
<key>showInSymbolList</key>
<integer>1</integer>
<key>showInIndexedSymbolList</key>
<integer>0</integer>
<key>symbolTransformation</key>
<string>
s/#pragma MARK/ ---- /g;
</string>
</dict>
</dict>
</plist>
This doesn’t get you all the way there; for one thing, #ifdef
and #endif
directives are caught with this rule. Additionally it doesn’t visually indent everything that follows which IIRC XCode does. However, it’s a good starting point for seeing what is going on.
If you wanted to actually do this with special single line comments and not a #pragma
I believe you would need to enhance the syntax highlighting for the language(s) you’re targetting to match such comments and give them a scope that you can uniquely target.