Changing font for keywords only in Sublime Text 3 [duplicate] - sublimetext3

Apologies if this has already been answered but I couldn't find any duplicates.
Is it possible to set font sizes on a per-token basis in Sublime Text 2? For example, all 'function' tokens would be size 10 whereas 'functionName' would be size 30? I've put together a rough mock-up of what I want to achieve:
The motivation here is to make it easier for you to focus on the important parts of your code - especially when skimming. I would suspect that such a thing should be possible given that, by default, ST2 already applies different fonts to different tokens (e.g. 'var' vs. 'c = a;' in switchVars()).
If it is not a feature, does ST2 provide the ability to implement this as a plugin? Thanks a lot!

Unfortunately, this is not possible, as there are no directives in the API or in color schemes for dealing with font size at that level of granularity.
However, it is possible to provide additional highlighting to your color scheme (.tmTheme file) so that function definitions stand out. It looks like you're using Monokai, so open Packages/Color Scheme - Default/Monokai.tmTheme and add the following to the end, just before the final </array>:
<dict>
<key>name</key>
<string>Function definition</string>
<key>scope</key>
<string>meta.function</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#000080</string>
</dict>
</dict>
This will highlight your function definition lines in a dark blue:
It also works for alternate function definition syntaxes:
Good luck!

Related

How to modify Sublime Text 3 color scheme file "filename.tmTheme" to apply background color to all occurrences of a matching text when double click?

I think my question itself is quite descriptive and clear to understand what I require.
Actually, I want to apply background color to all occurrences of a matching text when I double click a text or variable.
I surfed entire Internet by Googling tremendously but couldn't find any property that can be used in my case. So that's why I am asking here. My last hope is STO.
What needs to be added or modify in my Sublime Text 3 color scheme file, e. g. "filename.tmTheme"?
I am having ST3 Version 3.2.2, Build 3211.
In given screenshot, you can see that matching occurrences ($ch in this case) are highlighted with yellow border. I want them to be in yellow background color like Dreamweaver does. Any chance?
My current settings in color scheme file:
<key>settings</key>
<dict>
<key>background</key>
<string>#fff</string>
<key>bracketContentsForeground</key>
<string>#f00</string>
<key>bracketContentsOptions</key>
<string>foreground underline</string>
<key>bracketsForeground</key>
<string>#f00</string>
<key>bracketsOptions</key>
<string>foreground underline</string>
<key>caret</key>
<string>#000</string>
<key>foreground</key>
<string>#000</string>
<key>gutter</key>
<string>#f2f2f2</string>
<key>gutterForeground</key>
<string>#999</string>
<key>highlight</key>
<string>#ff0</string>
<key>invisibles</key>
<string>#999</string>
<key>lineHighlight</key>
<string>#e8e8ff</string>
<key>selection</key>
<string>#0078d7</string>
<key>selectionBorder</key>
<string>#0078d7</string>
<key>selectionBorderWidth</key>
<string>2</string>
<key>selectionCornerStyle</key>
<string>square</string>
<key>selectionForeground</key>
<string>#fff</string>
<key>tagsForeground</key>
<string>#f00</string>
<key>tagsOptions</key>
<string>foreground underline</string>
</dict>

Sublime Text 3 - how to remove red background

How to remove that Red background in Sublime. There is some slash in that line "/" when I remove that slash red background disappears. But how do I remove that red background permanently
just providing more information on this in case someone else looks into this. As mention above, you would need to edit the XML file associated to the color scheme you're using. If you're using a theme from package control you most likely would need to utilize PackageResourceViewer to open the XML file.
Once you've located the file, you would simply need to comment out the background values for the Invalid key.
For example refer to the snippet below:
<dict>
<key>name</key>
<string>Invalid</string>
<key>scope</key>
<string>invalid</string>
<key>settings</key>
<dict>
<!--key>background</key-->
<!--string>#ec5f67</string-->
<key>foreground</key>
<string>#ffffff</string>
</dict>
</dict>
This way you can maintain the syntax colors and suppress the annoying red highlight/background when there is an invalid syntax.

How do I color the stippled underline in Sublime Text 3?

I have a plugin using the add_regions command to draw underlines for certain regions.
I also have a custom tmLanguage and tmTheme, so I can control font style/foreground color etc. for scopes I have set.
Now, I'm trying to get my underlines to be a specific color (and not the default white-ish ST3 color)... I know this is possible because the spellcheck in ST3 has a red squiggly underline.
I've poked at changing the scope/settings/keys etc. in my tmTheme and my plugin's add_regions command, but nothing seems to stick.
Any direction would be very helpful!
You can simply set up a dummy scope in your tmTheme file with the foreground setting valued to the color you want your underline to be. Then pass in that scope name to the add_regions function call.
Example for yellow underline...
In the tmTheme file:
...
<dict>
<key>name</key>
<string>Yellow Underline</string>
<key>scope</key>
<string>underline.yellow.text</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FFFF00</string>
</dict>
</dict>
...
In your plugin:
# ...
# set regions variable above
view.add_regions('key', regions, 'underline.yellow.text', '', sublime.DRAW_STIPPLED_UNDERLINE | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE)
# ...
Ta-da! You should have yellow underlines now :)

how to edit and change only "function" and "class" keyword to bold in sublime-text-2?

i have searched through search engine and didnt find my solution for changing only the "function" and "class" keyword to bold in sublime text 2(especially for php)
all i know is how to change all text/code to bold is by adding the user settings
font_options: ["bold"]
but i dont know how to change only specific keyword to become bold.
so the question is :
- how to edit sublime-text-2 so it displays keyword "function" and "class" to bold
edited
whenn i change the font_options to ==> font_options: ["bold"]
ST2 displays function and class keyword in italic, then i tried to install ST2 in windows and it displays function and class keyword in italic too.
So i copy the theme xml file from windows to my ubuntu and nothing happen when in normal font , still the same, no italic/bold keywords , just displaying different colors for each keyword
is this normal thing? my main install ST2 is in ubuntu 12.04 64 bit LTS
Open your theme file (<sublime text 2 config folder>/Packages/Color Schemes - Default/themename.tmTheme) and change this key:
<dict>
<key>name</key>
<string>Class name</string>
<key>scope</key>
<string>entity.name.class</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>underline</string> <!-- This thing -->
<key>foreground</key>
<string>#69D2E7</string>
</dict>
</dict>
Answer copied from ST Forum:
For bold (or, similarly, for italic) to work you need:
A color scheme that uses bold.
A monospace font.
A font that includes bold weight.

Change font-size for a single scope in Sublime Text 2 [duplicate]

This question already has an answer here:
Per-token font size in Sublime Text 2
(1 answer)
Closed 6 years ago.
Is it possible in a .tmTheme file for Sublime Text 2 to change the font-size in a single scope?
I couldn't find any documentation on what keys I had available.
What I really want to do, is make the name of the section in \section{name} in LaTeX in a different size font, with something like:
<dict>
<key>scope</key>
<string>entity.name.section.latex</string>
<key>settings</key>
<dict>
<key>font_size</key>
<string>20</string>
</dict>
</dict>
Unfortunately, this does not seem to be possible in Sublime Text 2 or 3. See this post for details Per-token font size in Sublime Text 2.
I have also tried to change font-family (e.g. consolas or helvetica) based on scope, which seems to be equally impossible. I'm not sure why this functionality isn't available, so maybe if you send Jon Skinner an email, he'll fix it for you ;)

Resources