Sublime Forum

Syntax highlight issue

#1

Hi, I found one issue with syntax highlighting:

variable name in double quotes is interpolated and should have variable haighliting, look how it is in VIM:

[size=85]my $num = 99;
print “number = $num\n”;[/size]

but in Sublime Text the same script highlighting works incorrect:

[size=85]my $num = 99;
print “number = $num\n”;[/size]

so variable $num is not recognized in double quotes. Arrays @num - either not recognized. Do you know how to fix highlighting?

0 Likes

#2

Is that in PHP?

If yes, variables in double quotes are actually captured by the default syntax definition.
But, it’s not rendered in the default theme.

0 Likes

#3

no it is Perl

0 Likes

#4

I know nothing about Perl but I just tried it.
It’s the same problem as PHP’s.

Manually adding a color for the scope to your color theme is a solution (but it’s dirty).


0 Likes

#5

thanks, in what file did you add color theme?

0 Likes

#6

For me, under Windows, the default color theme file is in

C:\Program Files\Sublime Text 3\Packages\Color Scheme - Default.sublime-package

The “.sublime-package” file is basically a ZIP tarball so you can decompress it using zip/winrar/7zip or whatever.
Extract “Monokai.tmTheme” (maybe you are not using this one or you are using a non-default color theme) into

C:\Program Files\Sublime Text 3\Data\Packages

Modify user settings to use a new color theme in Toolbar » Preferences » Settings-User with

"color_scheme": "Packages/Monokai.tmTheme",

Add a customized coloring rule into “Monokai.tmTheme.”

<dict> <key>name</key> <string>Perl - Variable in double quotes</string> <key>scope</key> <string>string.quoted.double.perl variable.other.readwrite.global.perl</string> <key>settings</key> <dict> <key>fontStyle</key> <string>bold italic</string> <key>foreground</key> <string>#FF7F00</string> </dict> </dict>

0 Likes

#7

thanks for this info, bu I am using Sublime Text 2, and I dont have directories that you showed.

I have this dir: C:\Users\Alx\AppData\Roaming\Sublime Text 2\Packages

it contains Programming Languages dirs, is it correct dir for me?

btw, may be it is better to fix this file:

C:\Users\Alx\AppData\Roaming\Sublime Text 2\Packages\Perl\Perl.tmLanguage

0 Likes

#8

[quote=“swserg”]thanks for this info, bu I am using Sublime Text 2, and I dont have directories that you showed.

I have this dir: C:\Users\Alx\AppData\Roaming\Sublime Text 2\Packages

it contains Programming Languages dirs, is it correct dir for me?

btw, may be it is better to fix this file:

C:\Users\Alx\AppData\Roaming\Sublime Text 2\Packages\Perl\Perl.tmLanguage[/quote]

Both is okay.
I think ST2 is no longer maintained but you may use a 3rd-party color theme which is still maintained.
So fix .tmLanguage would be better.

0 Likes

#9

[quote]The current version of Sublime Text 2 is 2.0.2.

Sublime Text 3 is currently in beta, and contains many improvements over Sublime Text 2.[/quote]

assuming this, your statement is rather strange, I downloaded the current stable version, it is 2.0.2

0 Likes

#10

[quote=“swserg”]

[quote]The current version of Sublime Text 2 is 2.0.2.

Sublime Text 3 is currently in beta, and contains many improvements over Sublime Text 2.[/quote]

assuming this, your statement is rather strange, I downloaded the current stable version, it is 2.0.2[/quote]

Personally, I think Sublime Text 3’s “Beta” label is somewhat of a misnomer at this point. ST3 has much better support in terms of third-party plugins, has many core improvements and is very stable in my experience.

0 Likes

#11

[quote=“jfcherng”]I know nothing about Perl but I just tried it.
It’s the same problem as PHP’s.

Manually adding a color for the scope to your color theme is a solution (but it’s dirty).


http://i.imgur.com/VoHJ286.png[/quote]

by the way, what tool did you use to identify the scope? I inserted the same into perl color scheme, but it doesnt work :frowning: may be in ST 2.02 we use another scope

0 Likes

#12

[quote=“swserg”]
by the way, what tool did you use to identify the scope? I inserted the same into perl color scheme, but it doesnt work :frowning: may be in ST 2.02 we use another scope[/quote]

It’s packagecontrol.io/packages/ScopeHunter .

0 Likes

#13

well, sublime 2 doesnt have that package, looks like i need to go to sublime 3

0 Likes

#14

I installed ST3 with Package Control, however i cannot find ScopeHunter in the installable packages(ctrl+shift+p), how may i install it?

0 Likes

#15

I am not sure what happened.
Just downloaded a clean ST3 and installed Package Control.
ScopeHunter was found.

0 Likes

#16

[quote=“jfcherng”]

I am not sure what happened.
Just downloaded a clean ST3 and installed Package Control.
ScopeHunter was found.[/quote]

thanks for your input, i solved it.

For those who faced the same issue:

  1. run sublime text3 with admin privileges
  2. open ctrl+shit+p
  3. Choose Package Control: advanced package install
  4. put into: ScopeHunter (warning: case sensitive)
  5. hit enter, and it will be installed.

to see the scope: put cursor into needed place and hit ctrl+shit+p and choose: Scope: Show scope under cursor

0 Likes

#17

You don’t need a package to show the scope. Without scope hunter it just appears in the status bar (default binding is ctrl+alt+shift+p)
The package ScopeAlways allows you to always display it (with a toggle)

0 Likes