diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index aa243c5e..35174be8 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -257,6 +257,10 @@ canon.addCommand({ } }); canon.addCommand({ +canon.addCommand({ + name: "splitline", + exec: function(env, args, request) { env.editor.splitLine(); } +}); name: "transposeletters", exec: function(env, args, request) { env.editor.transposeLetters(); } }); diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 996efabe..2a9989dc 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -565,6 +565,19 @@ var Editor =function(renderer, session) { this.clearSelection(); }; + this.splitLine = function() { + if (this.$readOnly) + return; + + if (!this.selection.isEmpty()) { + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + } + + var cursor = this.getCursorPosition(); + this.insert("\n"); + this.moveCursorToPosition(cursor); + }; this.transposeLetters = function() { if (this.$readOnly)