In sublime text 4, how to hide embeded code's symbols in the `go to symbol` panel when in a markdown file? - sublimetext4

In sublime text 4, now go to symbol will show mixed symbols. For example. if I have a markdown file, and inside the file there is some go snippet code, go to symbol will show both markdown source’s symbol and go source’s symbol mixed, and the mixed mess make go to symbol help less to show the markdown’s structure.
So is there a way to restrict the go to symbol only show symbol from the main source? like inside a *.md file, only show markdown’s symbol? Like the old days?

See: https://forum.sublimetext.com/t/how-to-restrict-go-to-symbol-only-show-symbol-from-one-source/64066
There is a patch to do this: https://github.com/deathaxe/sublime-packages/blob/838d21fe511b993ccaff86daa7dac663b58ecf91/Markdown/Symbol%20List%20-%20Hide.tmPreferences
But it's not released yet. You can manually create a Symbol List - Hide.tmPreferences file under sublime text's Pacakges/Markdown/ folder with the content:
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>
text.html.markdown markup.raw.code-fence,
text.html.markdown meta.toc-list.id
</string>
<key>settings</key>
<dict>
<key>showInSymbolList</key>
<integer>0</integer>
<key>showInIndexedSymbolList</key>
<integer>0</integer>
</dict>
</dict>
</plist>
To do this, you may need install PacakgeSourceViewer package, and extract the Markdown package first.

Related

Sublime Text Default HTML comments

It looks like when I installed a PHP Twig syntax package it altered the default HTML comment output from <!-- … --> to {# … #}
So, I removed the package, but it still outputs the comment as Twig when I press the keyboard shortcut.
BTW, the key mapping is correct (super+alt+forward_slash), but it's returning a Twig formatted comment instead of an HTML comment.
How do I get back to <!-- … -->
???
It seems as if there is something a little hinky with either your installation of the package or it's removal, so some investigation will be needed in order to resolve the problem.
For background, the settings information for what character or characters to use for comments (either single line or block) is provided by a file of type tmPreferences (not tmLanguage as is erroneously described in the tutorial that you linked to in the comments on your question).
The name of the file and the package that it is contained in don't matter (except in that they control the order the files are loaded in), only the content of said file.
The package that you installed (PHP-Twig) includes the file Preferences/Comments.tmPreferences to set the comments to use in twig files. As seen in this commit, the file contains this subset of information that controls comments:
<key>scope</key>
<string>text.html.twig</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>{# </string>
</dict>
<dict>
<key>name</key>
<string>TM_COMMENT_END</string>
<key>value</key>
<string> #}</string>
</dict>
</array>
</dict>
This says that for the syntax scope text.html.twig, the shellVariables settings TM_COMMENT_START and TM_COMMENT_STOP are {# and #} respectively. With this in place, any time the scope at the cursor location matches text.html.twig and you trigger the comment command, these are used to wrap the commented section.
With that said, these comment characters should only apply when the scope matches text.html.twig. The scope used in regular HTML files is text.html.basic (assuming you're using the HTML package that ships with Sublime), and so it should not match and the comments should not be used there.
You can check the scope of any particular location by using Tools > Developer > Show Scope Name... from the menu or the key binding visible for it from the menu in order to verify.
If you were seeing these comments appear in regular HTML files as well, you may have set Sublime to use the twig syntax for HTML files either intentionally or accidentally, which you can check by checking the right side of the status bar which tells you the syntax that's in use.
On the other hand the problem should also have resolved itself when you removed the package, since that would have removed the tmPreferences file that's providing the comment settings.
I would perform the following checks to see if they have any effect:
Open up an HTML file and verify that the status bar says that it's a file of type HTML and not HTML (Twig) or something else. If it's something else, use View > Syntax > Open all with current syntax as from the menu to set it back to HTML and see if that fixes the problem for HTML files.
Add "PHP-Twig" to the ignored_packages setting in your preferences and see if that helps.
If the file type is wrong or adding PHP-Twig to the list of ignored packages solves the problem, then the package is still installed. If you used Package Control to install it, try removing it again and see if that has any effect (check the Sublime console for errors as well in case the removal is failing for some reason).
You could also select Preferences > Browse Packages from the menu to open the location where Sublime stores all of your unpacked packages. PHP-Twig should not install unpacked, so if you see a folder by that name delete it or move it away from that folder so Sublime can't see it.
From that Packages folder, go up one level in the file hierarchy and then go into the Installed packages folder; this is where user packages that are installed as sublime-package files (most packages fall into this category) are stored and verify that there is not a PHP-Twig.sublime-package file. As above, if you see a file by that name, move it away from that folder so Sublime can't see it and see if that helps.
Failing that the only obvious things that come to mind would be stray tmPreferences files somewhere. The most likely location for such a thing would be one of the folders in the Packages folder (the first one we checked above).

Add custom Markers that will be shown in the Goto Symbol (Cmd+R) window

I've posted this exact same question in the ST forum plugin dev threads
https://forum.sublimetext.com/t/add-custom-markers-that-will-be-shown-in-the-goto-symbol-cmd-r-window/23772
I've been using ST for a couple of years,
I'd like some guidance in first knowing if want I want to accomplish is possible through a plugin development, and if the answer is positive, maybe some reference as to where to start looking to develop this feature.
I would like to include some kind of marker that when placed in code, it includes a new entry in the list that is displayed in the Goto Symbol (Cmd+R) window. The closest example I have now is from Xcode, where in the source code you can include a comment with the "MARK:" keyword and it will render a new section in the top header bar of the editor (which is the equivalent of the goto symbol in ST).
When working with large files this feature would be of tremendous help because it allows to organize the blocks of code based on custom criteria regarding the logical relationships around it and not just the sequence of functions that exist in the file.
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.

Highlight the jQuery $ variable in Sublime Text 3 (build 3103)

In Feb 2016, the update to build 3103 broke a custom theme of mine, mostly in regard to Javascript. I really miss the ability to target the $, it seems that it's now under the scope:
meta.function-call.with-arguments.js variable.function.js when modifying the theme.
I want to know if there's a way to bypass or over-rule the $ sign, perhaps some REGEX or a way to add scope into the .tmLanguage file, so that I may color it differently from other "variable functions".
Until the unpaid/non-dev Sublime Text 3 is updated >= build 3106, follow these instructions to theme your $ variable in JavaScript or otherwise allow updated themes to function properly.
On your computer, go to Sublime Text 3\Data\Packages and make a new folder named "JavaScript", exactly that.
Visit https://github.com/sublimehq/Packages/blob/master/JavaScript/JavaScript.sublime-syntax
Copy that text, save as JavaScript.sublime-syntax in your new JavaScript folder. This will update the grammar to accept $ as its own scope.
You can now target variable.other.dollar.only.js and punctuation.dollar.js
Modifying Your Theme
Add this to your favorite theme if it hasn't been updated! Change the foreground to your liking.
<dict>
<key>name</key>
<string>jQuery $</string>
<key>scope</key>
<string>punctuation.dollar.js</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#b3935cff</string>
</dict>
</dict>

Text editing - insert comments (#) in Ubuntu with gedit or other text editor

I am programming in a dedicated language called macro language.
To comment I need to add # at the beginning of the line.
What I want is, in order to spare time, to comment several lines of code at same time with gedit or other program (gedit is nice in terms of the colors, which make the code more readable).
How can I do it?
Thank you in advance.
Possibly need # apt-get install gedit-plugins.
Then go to edit > preferences > plugins > enable "code comment".
Then use ctrl-m to comment and ctrl-shift-m to uncomment.
(Technically, I think this would go in SuperUser though.)
There is a plugin for gedit, which should help for your needs.
You can get this from github:
https://github.com/jessevdk/gedit-multi-edit
You can specify a custom language definition by putting the below text (with ... replaced with the rest of the language definition) in ~/.local/share/gtksourceview-3.0/language-specs/thingy.lang:
<?xml version="1.0" encoding="UTF-8"?>
<language id="thingy" _name="Thingy Code" version="2.0" _section="Sources">
<metadata>
<property name="line-comment-start"># </property>
...
</metadata>
<styles>
...
</styles>
<definitions>
...
</definitions>
</language>
You'll probably want to base your language spec off of one of the langage specs in /usr/share/gtksourceview-3.0/language-specs/, since it's kind of a pain to get a working language spec from scratch (especially since the XML parser error messages are anywhere from useless to worse).

How to make notepad++ treat csproj files as XML automatically?

I often use notepad++ for editing of the csproj files. And I always need to go to the Language menu and select XML in order to get syntax highlighting.
Is it possible to configure notepad++ to treat csproj files as XML automatically?
Open Settings -> Style Configurator, select "XML" in "Language" list, add "csproj" (without quotes) to "User ext" box.
Edit the file langs.xml in the notepad++ folder.
Change this
<Language name="xml" ext="xml xsml xsl xsd kml wsdl" commentLine="" commentStart="<!--" commentEnd="-->">
</Language>
by
<Language name="xml" ext="xml xsml xsl xsd kml wsdl csproj" commentLine="" commentStart="<!--" commentEnd="-->">
</Language>

Resources