]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/lib/operators/indent-operators.coffee
Update atoms
[rbdr/dotfiles] / atom / packages / vim-mode / lib / operators / indent-operators.coffee
1 _ = require 'underscore-plus'
2 {Operator} = require './general-operators'
3
4 class AdjustIndentation extends Operator
5 execute: (count) ->
6 mode = @vimState.mode
7 @motion.select(count)
8 originalRanges = @editor.getSelectedBufferRanges()
9
10 if mode is 'visual'
11 @editor.transact =>
12 _.times(count ? 1, => @indent())
13 else
14 @indent()
15
16 @editor.clearSelections()
17 @editor.getLastCursor().setBufferPosition([originalRanges.shift().start.row, 0])
18 for range in originalRanges
19 @editor.addCursorAtBufferPosition([range.start.row, 0])
20 @editor.moveToFirstCharacterOfLine()
21 @vimState.activateNormalMode()
22
23 class Indent extends AdjustIndentation
24 indent: ->
25 @editor.indentSelectedRows()
26
27 class Outdent extends AdjustIndentation
28 indent: ->
29 @editor.outdentSelectedRows()
30
31 class Autoindent extends AdjustIndentation
32 indent: ->
33 @editor.autoIndentSelectedRows()
34
35 module.exports = {Indent, Outdent, Autoindent}