Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ctrl+w (delete previous word) and ctrl+u (erase start to cursor)

  • Loading branch information...
commit a82215016adf40080ea440bed52332336952f2de 1 parent 2e542c1
@thricedotted authored
Showing with 30 additions and 13 deletions.
  1. +25 −12 functions.js
  2. +5 −1 vimflowy.js
View
37 functions.js
@@ -62,19 +62,32 @@ jQuery.fn.addGlobalKeyboardShortcuts = function () {
};
// command functions
-var moveWordForward = function (e) {
- e.preventDefault();
-
- var index = indexOfNextCaret($(e.target).getCaret().start, $(e.target).val(), { shift: true });
- if (index > 0) {
- $(e.target).setCaret(index);
- } else {
- $(e.target).setCaret($(e.target).val().length);
- $(e.target).rightArrowHandler();
- }
- return false;
-};
var commands = {
+ deleteWordBack: function (e) {
+ e.preventDefault();
+
+ var index = indexOfNextCaret($(e.target).getCaret().start, $(e.target).val(), { backward: true, shift: true });
+
+ var n_back = $(e.target).getCaret().start - index;
+
+ for (var i=0; i < n_back; i++) {
+ $(e.target).simulate("key-sequence", {sequence: "{backspace}", triggerKeyEvents: true });
+ }
+ return false;
+ },
+
+ deleteItemBack: function (e) {
+ e.preventDefault();
+
+ var n_back = $(e.target).getCaret().start;
+
+ for (var i=0; i < n_back; i++) {
+ $(e.target).simulate("key-sequence", {sequence: "{backspace}", triggerKeyEvents: true });
+ }
+ return false;
+
+ },
+
moveWordForward: function (e) {
e.preventDefault();
View
6 vimflowy.js
@@ -28,7 +28,11 @@ var normalKeybindings = {
};
var insertKeybindings = {
- "esc": enterNormalMode
+ "esc": enterNormalMode,
+
+ // TODO: this breaks tab closing (even more)!
+ "ctrl+w": commands.deleteWordBack,
+ "ctrl+u": commands.deleteItemBack
};
var alwaysKeybindings = {
Please sign in to comment.
Something went wrong with that request. Please try again.