Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying Sublime Text 2 for JS

I am almost a beginner to programming outside "Mathematica".

I use Sublime Text 2 and mostly need to code in JS, and I would like to use a different color theme than the one already present in preferences.

For example, I would like to use this theme

My attempt installing Eclipse have yet failed, I am using a mac with the latest version of Lion.

like image 537
500 Avatar asked May 17 '12 13:05

500


People also ask

Can Sublime Text be used for JavaScript?

TypeScript, JSX and TSX SupportUtilize all of the smart syntax-based features of Sublime Text within the modern JavaScript ecosystem.

Is Sublime Text better than Vscode?

Much like VS Code, Sublime gets lots of praises when it comes to performance and customization. Some say it's the fastest text editor for writing code. Not only in general performance but also to run fast searches across any number of files. It reaches this level of performance by being very, very lightweight.


1 Answers

Most themes have support for JavaScript syntax highlighting. If it does not appear automatically, it may be because SublimeText does not recognize the file as containing JavaScript. You can force it by going to View > Syntax > JavaScript > JavaScript.

If you need to define a particular syntax, you will have to build your own syntax definition. That guide has a step-by-step process.

I would suggest copying the existing JavaScript syntax definition and refining it further, if you need to add or change a few definitions. The syntax definitions are defined by regular expressions, and held within an XML file. If your variables can be differentiated by a specific regular expression, you will be able to color-code them with a separate rule.

Sublime Text 2: diff syntax highlighting with a light background color scheme gives a succinct example of updating a theme to show different colors for new syntax.

like image 102
tephyr Avatar answered Oct 12 '22 23:10

tephyr