mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Add h (move left) monvment to vimMode.
This commit is contained in:
@@ -39,6 +39,16 @@ describe "VimMode", ->
|
||||
expect(editor.buffer.getText()).toBe '1345'
|
||||
expect(editor.getCursor()).toEqual(column: 1, row: 0)
|
||||
|
||||
describe "the h/j/k/l keybindings", ->
|
||||
it "move the cursor left/up/down/right", ->
|
||||
editor.buffer.setText("12345\nabcde\nABCDE")
|
||||
editor.setCursor(column: 1, row: 1)
|
||||
|
||||
editor.trigger keydownEvent('h')
|
||||
expect(editor.getCursor()).toEqual(column: 0, row: 1)
|
||||
editor.trigger keydownEvent('h')
|
||||
expect(editor.getCursor()).toEqual(column: 0, row: 1)
|
||||
|
||||
describe "numeric prefix binding", ->
|
||||
it "repeats the following operation N times", ->
|
||||
editor.buffer.setText("12345")
|
||||
|
||||
@@ -23,3 +23,9 @@ module.exports =
|
||||
|
||||
isComplete: -> true
|
||||
|
||||
MoveLeft: class
|
||||
execute: (editor) ->
|
||||
{column, row} = editor.getCursor()
|
||||
editor.navigateLeft() if column > 0
|
||||
|
||||
isComplete: -> true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
_ = require 'underscore'
|
||||
$ = require 'jquery'
|
||||
{ NumericPrefix, DeleteChar } = require 'vim-mode-operators'
|
||||
{ NumericPrefix, DeleteChar, MoveLeft } = require 'vim-mode-operators'
|
||||
|
||||
module.exports =
|
||||
class VimMode
|
||||
@@ -19,6 +19,7 @@ class VimMode
|
||||
@editor.on 'command-mode:activate', => @activateCommandMode()
|
||||
@editor.on 'command-mode:delete-char', => @deleteChar()
|
||||
@editor.on 'command-mode:numeric-prefix', (e) => @numericPrefix(e)
|
||||
@editor.on 'command-mode:move-left', => @pushOperator(new MoveLeft)
|
||||
|
||||
activateInsertMode: ->
|
||||
@editor.removeClass('command-mode')
|
||||
@@ -38,6 +39,7 @@ class VimMode
|
||||
bindings =
|
||||
'i': 'insert-mode:activate'
|
||||
'x': 'command-mode:delete-char'
|
||||
'h': 'command-mode:move-left'
|
||||
for i in [0..9]
|
||||
bindings[i] = 'command-mode:numeric-prefix'
|
||||
bindings
|
||||
|
||||
Reference in New Issue
Block a user