diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index 0c555076..e729457e 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -242,10 +242,22 @@ canon.addCommand({ name: "backspace", exec: function(env, args, request) { env.editor.removeLeft(); } }); +canon.addCommand({ + name: "removetolinestart", + exec: function(env, args, request) { env.editor.removeToLineStart(); } +}); canon.addCommand({ name: "removetolineend", exec: function(env, args, request) { env.editor.removeToLineEnd(); } }); +canon.addCommand({ + name: "removewordleft", + exec: function(env, args, request) { env.editor.removeWordLeft(); } +}); +canon.addCommand({ + name: "removewordright", + exec: function(env, args, request) { env.editor.removeWordRight(); } +}); canon.addCommand({ name: "outdent", exec: function(env, args, request) { env.editor.blockOutdent(); } diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 109272a2..c878306e 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -567,6 +567,39 @@ var Editor =function(renderer, session) { this.clearSelection(); }; + this.removeWordRight = function() { + if (this.$readOnly) + return; + + if (this.selection.isEmpty()) + this.selection.selectWordRight(); + + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + }; + + this.removeWordLeft = function() { + if (this.$readOnly) + return; + + if (this.selection.isEmpty()) + this.selection.selectWordLeft(); + + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + }; + + this.removeToLineStart = function() { + if (this.$readOnly) + return; + + if (this.selection.isEmpty()) + this.selection.selectLineStart(); + + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + }; + this.removeToLineEnd = function() { if (this.$readOnly) return;