diff options
Diffstat (limited to 'atom/packages/vim-mode/lib/motions/move-to-mark-motion.coffee')
| -rw-r--r-- | atom/packages/vim-mode/lib/motions/move-to-mark-motion.coffee | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/atom/packages/vim-mode/lib/motions/move-to-mark-motion.coffee b/atom/packages/vim-mode/lib/motions/move-to-mark-motion.coffee new file mode 100644 index 0000000..0187620 --- /dev/null +++ b/atom/packages/vim-mode/lib/motions/move-to-mark-motion.coffee @@ -0,0 +1,25 @@ +{MotionWithInput, MoveToFirstCharacterOfLine} = require './general-motions' +{ViewModel} = require '../view-models/view-model' +{Point, Range} = require 'atom' + +module.exports = +class MoveToMark extends MotionWithInput + operatesInclusively: false + + constructor: (@editor, @vimState, @linewise=true) -> + super(@editor, @vimState) + @operatesLinewise = @linewise + @viewModel = new ViewModel(this, class: 'move-to-mark', singleChar: true, hidden: true) + + isLinewise: -> @linewise + + moveCursor: (cursor, count=1) -> + markPosition = @vimState.getMark(@input.characters) + + if @input.characters is '`' # double '`' pressed + markPosition ?= [0, 0] # if markPosition not set, go to the beginning of the file + @vimState.setMark('`', cursor.getBufferPosition()) + + cursor.setBufferPosition(markPosition) if markPosition? + if @linewise + cursor.moveToFirstCharacterOfLine() |