aboutsummaryrefslogtreecommitdiff
path: root/atom/packages/vim-surround/lib/command/surround.coffee
blob: e939f78a3ae9ef3e5dcc367735e5463c0d8d5ee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{CompositeDisposable} = require 'atom'

Base = require './base'

module.exports = class Surround extends Base
  constructor: (config) ->
    @command = config.surroundCommand
    @context = "atom-text-editor.vim-mode.visual-mode"
    super config

  getName: (key) -> "surround-#{key}"

  getRunner: (left, right) -> ->
    editor = atom.workspace.getActiveTextEditor()
    editor.transact ->
      editor.selections.forEach (selection) ->
        text = selection.getText()
        selection.insertText "#{left}#{text}#{right}"