diff --git a/lib/ace/keyboard/vim/maps/motions.js b/lib/ace/keyboard/vim/maps/motions.js index 91c8b8af..ae457d54 100644 --- a/lib/ace/keyboard/vim/maps/motions.js +++ b/lib/ace/keyboard/vim/maps/motions.js @@ -481,10 +481,17 @@ module.exports = { } }, "$": { - nav: function(editor) { + handlesCount: true, + nav: function(editor, range, count, param) { + if (count > 1) { + editor.navigateDown(count-1); + } editor.navigateLineEnd(); }, - sel: function(editor) { + sel: function(editor, range, count, param) { + if (count > 1) { + editor.selection.moveCursorBy(count-1, 0); + } editor.selection.selectLineEnd(); } }, @@ -660,5 +667,7 @@ module.exports.up = module.exports.k; module.exports.down = module.exports.j; module.exports.pagedown = module.exports["ctrl-d"]; module.exports.pageup = module.exports["ctrl-u"]; +module.exports.home = module.exports["0"]; +module.exports.end = module.exports["$"]; }); diff --git a/lib/ace/keyboard/vim_test.js b/lib/ace/keyboard/vim_test.js index 15aeb568..3e81c007 100644 --- a/lib/ace/keyboard/vim_test.js +++ b/lib/ace/keyboard/vim_test.js @@ -251,7 +251,7 @@ addTest("Word movement [PARTIAL]", "03", "1", function() { */ }); -addTest("Moving to the start or end of a line [PARTIAL]", "03", "2", function() { +addTest("Moving to the start or end of a line", "03", "2", function() { var text = " This is a line with example text"; var textLength = text.length; initEditor(text); @@ -259,22 +259,18 @@ addTest("Moving to the start or end of a line [PARTIAL]", "03", "2", function() assertPosition(0, 36); sendKeys("0"); assertPosition(0, 0); -/* "End" and "Home" fails sendKeys("End"); assertPosition(0, 36); sendKeys("Home"); assertPosition(0, 0); -*/ sendKeys("^"); assertPosition(0, 5); sendKeys("$^"); assertPosition(0, 5); sendKeys("ddaA young intelligent turtle\nFound programming UNIX a hurdle", "Esc", "k0"); assertPosition(0, 0); -/* $ fails sendKeys("2$"); assertPosition(1, 30); -*/ }); addTest("Moving to a character [PARTIAL]", "03", "3", function() {