0

「open_file」で作成したビューに挿入できないようです。

import sublime, sublime_plugin, re, os.path

class ExtractToViewCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    view = sublime.active_window().open_file("/path/to/some/file/that/doesnt/exist/yet")
    view.set_read_only(False)
    print(view.is_read_only())         # prints True!
    e = view.begin_edit()
    view.insert(e, 0, "hello world")   # returns 0!
    view.end_edit(e)

ここでの私の目標は、選択したテキストを新しいファイルに抽出するプラグインを作成することです。new_fileの代わりに使用するように変更すると、挿入は問題なく機能しopen_fileます。私が見逃しているアイデアはありますか?

4

1 に答える 1