Sublime Forum

Change indentation in "Goto Symbol... " Dialog

#1

I work a lot with [Multi]Markdown files, I use my own fork of https://github.com/ttscoff/MarkdownEditing package and really like it.

Goto Symbol is a nice way of quickly navigating your source files, but the indentation is too small for me to quickly search in deeply nested structures. Is there any way to add more spaces/tabs to the indentation (not in the source files itself but in the dialog)?

0 Likes

#2

This is very easy to do. Edit the file “Packages/Markdown/Symbol List - Heading.tmPreferences”, line 6. Here’s an example that adds four spaces for each heading level (i.e., per #):

s/(?<=#)#/    /g;			# change all but first # to m-space

Bear in mind that this will get over-written by future Sublime updates. You can avoid this (sort of) by copying the file over to your Packages/User. (Call it something you can recognize, like “Symbol List - Markdown Heading.tmPreferences”.) Then rename “Packages/Markdown/Symbol List - Heading.tmPreferences” to “Packages/Markdown/Symbol List - Heading.foobar” (or whatever).

I’ve been looking for a less annoying way to override specific files inside packages that are installed by default, but I haven’t found it yet.

Hope this helps,
Alex

0 Likes

#3

I use TextMate for writing Latex files and rely heavily on TextMate’s goto symbol. I have held back on switching over to Sublime Text 2 because your goto symbol has a very different feel to it. First of all, your version lists all sections, subsections, etc., which is all I want to see, as well as all theorems, lemmas, equations, etc. The latter overloads my need for a slim outline. With no indentation, I cannot readily see the outline of my paper. Finally, the original TextMate goto symbol is “live”. That is, as I type a new section name, the same letters show up immediately in my goto symbol list. Since I constantly watch my outline as I create manuscripts, this blocks me from switching over to Sublime Text 2.

Jenny

0 Likes

#4

I am trying to create indents as you suggested above, but seem to be making some silly mistake. Here is the file I created by inserting the extra line:

<?xml version="1.0" encoding="UTF-8"?> name Symbol List: Heading scope text.html.markdown markup.heading.markdown settings showInSymbolList 1 symbolTransformation s/\s*#*\s*\z//g; # strip trailing space and #'s s/^#( *)\s+(.*)/$1$2/; # strip first # and space before title s/(?<=#)#/ /g; # change all but first # to m-space uuid C02A37C1-E770-472F-A13E-358FF0C6AD89

I got this error message from ST:

Error loading meta info from Packages/User/Symbol List - Markdown Heading.tmPreferences: Error parsing plist xml: Error document empty. In file "Packages/User/Symbol List - Markdown Heading.tmPreferences

I am afraid I know nothing about markdown.

Any help will be appreciated.

0 Likes

#5

Hi Jenny,

I haven’t use Sublime for writing LaTeX at all (and my LaTeX in general is rather rusty), so I don’t know if I can be of much help.

How you go about creating indents depends on what the scopes for the syntax are like. You can’t transplant this method from Markdown to LaTeX. (Markdown uses #s to markup sections, so you just convert these to spaces. LaTeX uses different markup so the regular expression that does the transformation won’t work. But see below.)

I imagine you did this by renaming the file mentioned in the error as I mentioned above. You should probably rename it back, since it’s not going to help you with your LaTeX woes. This was a bad suggestion, to be honest; as it turns out there’s a simpler way of overriding .tmPreference files. (See below.)

The default LaTeX package does not provide .tmPreference files, so my guess is that you’re using some other package which populates the Go To Symbol list. I looked at LaTeXTools, which is the most popular one. It contains two .tmPreferences:

  • Symbol List - Sections.tmPreferences – This uses the (sub)section/chapter scopes. From looking at the tmLanguage file and from what I remember from LaTeX, I think it’s possible to indent the sections in the Go To Symbol list, but it’s non-trivial, and I don’t have the time to fiddle with this right now. Because I’ve never used Textmate, it might help if you could post a link to a publically avaible .tex document along with a screenshot of the Go To list in Textmate. I will at least be able to tell you if it’s possible (according to my current understanding of Symbol Lists, which admittedly is far from perfect).

  • Symbol List - Labels.tmPreferences – This one is probably the one that’s populating the list with “theorems, lemmas, equations, etc.” The way to remove the labels from the Go To list is to create the following file called .tmPreferences, and saving it somewhere in Packages:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>name</key>
	<string>Symbol List</string>
	<key>scope</key>
	<string>variable.parameter.definition.label.latex, meta.definition.label.latex</string>
	<key>settings</key>
	<dict>
		<key>showInSymbolList</key>
		<integer>0</integer>
	</dict>
</dict>
</plist>

Hope this helps,
Alex

0 Likes

#6

Try this for indented sections:

(Save it somewhere as a .tmPreferences file; it should override the one from LaTeXTools.)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>name</key>
	<string>Symbol List</string>
	<key>scope</key>
	<string>meta.function.section.latex</string>
	<key>settings</key>
	<dict>
		<key>showInSymbolList</key>
		<integer>1</integer>
		<key>symbolTransformation</key>
		<string>
			s/^\\part(.*)/\U($1)/g;
			s/^\\chapter//g;
			s/^\\section/  /g;
			s/^\\subsection/    /g;
			s/^\\subsubsection/      /g;
			s/^(\s*)\*{0,1}\{(.*)\}\s*/$1$2/g;
		</string>
	</dict>
</dict>
</plist>

It’s not very elegant but I tried it on a few documents I randomly found on Google and I didn’t run into any issues. Let me know how it goes.

Alex

0 Likes

#7

I keep a repo with various Go To Symbol experiments here: github.com/alehandrof/BetterGoTo

I’ve added the LaTeX files I described above, along with some fixes (I had forgotten to account for (sub)paragraphs).

Don’t clone the repo, because it will change the definitions for CSS, etc.; just grab the LaTeX files.

You might also want to to look at Comment Bang which is a syntax agnostic way to create comments that appear in the Go To Symbol list. For LaTeX the syntax would be:

% ! This label will appear in the Go To Symbol list 

I find it useful for leaving “notes to self” so I can find my way around large documents.

Alex

0 Likes