
This):
- Code: Select all
with Edit(view) as edit:
edit.insert(0, 'hi\n')
edit.insert(0, 'more stuff\n')
----
Compare to:
ST2 edit:
- Code: Select all
edit = view.begin_edit()
view.insert(edit, 0, 'hi\n')
view.insert(edit, 0, 'more stuff\n')
view.end_edit(edit)
ST3 edit (repeat for erase, replace? or roll your own / use callbacks if you want multiple operations in a single edit):
- Code: Select all
class InsertCommand(sublime_plugin.TextCommand):
def run(self, edit, pos, text):
self.view.insert(edit, pos, text)
view.run_command('insert', {'pos': 0, 'text': 'hi\n'})
view.run_command('insert', {'pos': 0, 'text': 'more stuff\n'})