sublimetext2 - Adding syntax highlighting to Sublime Text for JavaScript - Stack Overflow

admin2025-04-19  0

i have a single problem, in my sublime text 2 the syntax highlight of javascript takes this code

this.init = function(){};
this.init : function(){},

painting of "this" in lightblue and "init" in green...

but in this case...

this.init = null;
this.init : null,

is not happening... i want to highlight "this.*" in all cases of use...

like for example

this.init = function()
this.init : function()
this.init : true
this.init = true

how can i do that???

i have a single problem, in my sublime text 2 the syntax highlight of javascript takes this code

this.init = function(){};
this.init : function(){},

painting of "this" in lightblue and "init" in green...

but in this case...

this.init = null;
this.init : null,

is not happening... i want to highlight "this.*" in all cases of use...

like for example

this.init = function()
this.init : function()
this.init : true
this.init = true

how can i do that???

Share edited Aug 19, 2014 at 0:56 Ben McCormick 25.7k12 gold badges55 silver badges71 bronze badges asked Aug 30, 2013 at 1:07 andrescabana86andrescabana86 1,7888 gold badges32 silver badges56 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

The default syntax highlighting for javascript in Sublime is not great.

I use JavascriptNext: https://github./Benvie/JavaScriptNext.tmLanguage

It improves on the default syntax hightlighting and also adds support for future ES6 syntax.

In your particular case it is more consistent on the coloring of the if values, though less consistent on the property values for the : syntax. But I think thats ok since its not actually valid syntax anyhow.

Adding to ben336's answer, I tested your code with my Neon Color Scheme and a few different JavaScript language definitions, including JavaScriptNext, which actually did look the best:

The scopes for the init method are interesting (all are source.js, of course) -

this.init = function(); // meta.property.js variable.other.property.js
this.init : function(); // meta.function.js meta.function.json.js entity.name.function.js
this.init : true; // meta.function.js constant.other.object.key.js string.unquoted.label.js
this.init = true; // meta.function.js meta.property.js variable.other.property.js

Since the last 3 are function scoped they should be colored bright green, but the third one has a string scope and the last one a variable.other scope, so they pick up those colorings instead.

If you'd like, I can try to finagle the theme's function scope selectors to color the last 3 consistently - just open an issue or let me know here and I'll see what I can do.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745057675a282502.html

最新回复(0)