]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - atom/packages/vim-mode/lib/operators/indent-operators.coffee
Adds editorconfig
[rbdr/dotfiles] / atom / packages / vim-mode / lib / operators / indent-operators.coffee
... / ...
CommitLineData
1_ = require 'underscore-plus'
2{Operator} = require './general-operators'
3
4class 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
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}