Permalink
Browse files

Add the - command.

  • Loading branch information...
1 parent 453bbe7 commit c7e1d84578ba6b48727fb3e27873b9c09e984901 @georgebrock georgebrock committed Dec 7, 2012
Showing with 35 additions and 0 deletions.
  1. +13 −0 js/normal_mode/motions.js
  2. +22 −0 tests/acceptance/motions.js
View
13 js/normal_mode/motions.js
@@ -281,6 +281,19 @@
" line after the cursor";
}
}
+ }),
+ '-': new C({
+ callback: function (vim, count) {
+ vim.moveCursorRelative(-count, '^');
+ },
+ description: function (count) {
+ if (count === 1) {
+ return "Move to the start of the previous line";
+ } else {
+ return "Move to the start of the " + U.ordinalize(count) +
+ " line before the cursor";
+ }
+ }
})
};
View
22 tests/acceptance/motions.js
@@ -309,3 +309,25 @@ describe("The return motion", function () {
expect(cursorPosition()).toEqual({row: 1, col: 0});
});
});
+
+describe("The minus motion", function () {
+ beforeEach(function () {
+ reset(" First\nSecond\nThird");
+ pressKeys("G");
+ });
+
+ it("moves the cursor to the start of the previous line", function () {
+ pressKeys("2l-");
+ expect(cursorPosition()).toEqual({row: 1, col: 0});
+ });
+
+ it("skips whitespace", function () {
+ pressKeys("--");
+ expect(cursorPosition()).toEqual({row: 0, col: 2});
+ });
+
+ it("accepts a numerical multiplier", function () {
+ pressKeys("2-");
+ expect(cursorPosition()).toEqual({row: 0, col: 2});
+ });
+});

0 comments on commit c7e1d84

Please sign in to comment.