]> git.r.bdr.sh - rbdr/dotfiles/blame - atom/packages/vim-mode/lib/operators/indent-operators.coffee
Remove ruby prompt
[rbdr/dotfiles] / atom / packages / vim-mode / lib / operators / indent-operators.coffee
CommitLineData
455f099b 1_ = require 'underscore-plus'
24c7594d
BB
2{Operator} = require './general-operators'
3
4class AdjustIndentation extends Operator
455f099b 5 execute: (count) ->
24c7594d
BB
6 mode = @vimState.mode
7 @motion.select(count)
455f099b 8 originalRanges = @editor.getSelectedBufferRanges()
24c7594d 9
455f099b
BB
10 if mode is 'visual'
11 @editor.transact =>
12 _.times(count ? 1, => @indent())
13 else
14 @indent()
24c7594d 15
455f099b
BB
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()
24c7594d
BB
22
23class Indent extends AdjustIndentation
24 indent: ->
25 @editor.indentSelectedRows()
26
27class Outdent extends AdjustIndentation
28 indent: ->
29 @editor.outdentSelectedRows()
30
31class Autoindent extends AdjustIndentation
32 indent: ->
33 @editor.autoIndentSelectedRows()
34
35module.exports = {Indent, Outdent, Autoindent}