Ace Syntax Highlighter

Now I have configured Ace to work within my editor so It’s time to add the feature of Syntax Highlighter.

Generally, we’ll manually set mode to editor like


for this File extension must be known to us so that we can manually add mode but we don’t know the file extension before hand. so we have to use some intermediator which will tell the file extension.

Ace editor already have a built-in functionality

i.e modelist

now How we can use it?
1. Initialize modelist
var modelist = ace.require("ace/ext/modelist");
2. Get the mode for particular file
var mode = modelist.getModeForPath(path).mode;
3. Set the mode to editor

That’s it, all this is done under javascript file.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s