Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
An example of making custom syntax extensions for GMEdit. This collapses `//hello` in a file to `//hi` in editor and back.
"name": "synext",
"description": "",
"scripts": ["synext.js"],
"stylesheets": []
(function() {
const SyntaxExtension = $gmedit["synext.SyntaxExtension"];
function MySynExt() {, "mySynExt", "My syntax extension");
MySynExt.prototype = GMEdit.extend(SyntaxExtension.prototype, {
preproc: function(codeEditor, gmlCode) {
return gmlCode.split("//hello").join("//hi");
postproc: function(codeEditor, gmlCode) {
return gmlCode.split("//hi").join("//hello");
function init() {
$gmedit["file.kind.KGml"].syntaxExtensions.push(new MySynExt());
GMEdit.register("synext", { init: init });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment