Sublime Forum

Is there a way to get the edit variable in ST3

#1

In order to insert something to the view, we need to get the edit variable. In ST2, this can be achieved by begin_edit. But in ST3, this method is no longer viable. The edit command can be achieved using TextCommand. But I find it hard to get it within a WindowCommand class. By reading other people’s code, I noticed them using two walkarounds:

  1. we can use the append command: new_view.run_command(‘append’, { ‘characters’: string, ‘force’: True, ‘scroll_to_end’: False })
  2. we can define a TextCommand and call that command.

But both ways are a little bit awkward. Does Sublime provide a smoother way in doing this?

0 Likes

#2

TextCommand is the way to go. You can use it as “function” by calling it with run_command and add arguments defined by your TextCommand.

0 Likes