 <p>Easiest way is to modify php_highlight_rules file and add <a href="https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/php_highlight_rules.js#L900" rel="nofollow">https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/php_highlight_rules.js#L900</a> a rule</p> <pre><code>{ token: "variable", regex: "%%\\w+%%" } </code></pre> <p>doing this dynamically instead, is a bit harder as ace doesn't provide convenient way to hook into mode creation, if you need to do that, perhaps you should open an issue on ace site on github.</p>