Reputation: 1454
Right now, the solarized theme will highlight variables in JavaScript if formatted like this:
var foo = function (arg1, arg2) {...}
but not like this:
var foo = function(arg1, arg2) {...}
Some industry standard style guides (e.g. AirBnB) have no space after the function keyword, so I'd like to modify my color scheme. Is this possible?
Upvotes: 0
Views: 222
Reputation: 102902
This is actually a single-character fix to a regex in the syntax definition. Select Preferences -> Browse Packages...
to open the Packages
folder in your operating system's file browser. Go to the JavaScript
directory and open JavaScript.tmLanguage
in Sublime with XML syntax. Scroll down to line 260, which should be this:
<string>\b(function)\s+([a-zA-Z_$]\w*)?\s*(\()(.*?)(\))</string>
Change it to this:
<string>\b(function)\s*([a-zA-Z_$]\w*)?\s*(\()(.*?)(\))</string>
<!-- ^ -->
where the \s+
after (function)
becomes \s*
. \s
is any whitespace character, and the +
after it means match one or more
. Changing +
to *
means match zero or more
, which is what we want.
Save the file, restart Sublime (just in case), and you should be all set.
Note for Sublime Text 3 users:
Packages in ST3 are now stored in zipped .sublime-package
files, so you'll need an extra step. Install PackageResourceViewer
from Package Control, then open the Command Palette and select PackageResourceViewer: Open Resource
. Scroll down to JavaScript
, select it, then scroll down to JavaScript.tmLanguage
and select it. You can now edit the file as above, and when you save it, it will automatically create a JavaScript
folder in Packages
, with the .tmLanguage
file inside it.
Upvotes: 2