aboutsummaryrefslogtreecommitdiff
path: root/atom/packages/vim-mode/lib/operators/indent-operators.coffee
blob: 0ad37e0296d984729d61ca60abe219b362f194bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{Operator} = require './general-operators'

class AdjustIndentation extends Operator
  execute: (count=1) ->
    mode = @vimState.mode
    @motion.select(count)
    {start} = @editor.getSelectedBufferRange()

    @indent()

    if mode isnt 'visual'
      @editor.setCursorBufferPosition([start.row, 0])
      @editor.moveToFirstCharacterOfLine()
      @vimState.activateCommandMode()

class Indent extends AdjustIndentation
  indent: ->
    @editor.indentSelectedRows()

class Outdent extends AdjustIndentation
  indent: ->
    @editor.outdentSelectedRows()

class Autoindent extends AdjustIndentation
  indent: ->
    @editor.autoIndentSelectedRows()

module.exports = {Indent, Outdent, Autoindent}