diff options
| author | Ben Beltran <ben@nsovocal.com> | 2015-07-10 11:12:25 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2015-07-10 11:12:25 -0500 |
| commit | 24c7594d62d8d7fbbcdb64b11ce4adc5d8e6991a (patch) | |
| tree | ded312222bb108923da1820ba40b04d710d20e5b /atom/packages/vim-mode/lib/motions/move-to-mark-motion.coffee | |
| parent | eb786e82d170e2abc351a432ade616d6ecdeeb6b (diff) | |
Adds atom
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() |