2013-11-24 7 views
12


からすべてのテキストを取得します。私は、ウィンドウ内のすべてのテキストを選択することが可能に取得し、別のウィンドウにコピーします。
コード:崇高なテキスト3 API:私は今の崇高なテキスト3. <br> 用のプラグインを作成しようとしていますファイル

import sublime, sublime_plugin 

class PrintCodeCommand(sublime_plugin.WindowCommand): 
    def run(self): 
     # for each caracter, add it to a string with the substr method 
     s = "" 
     for x in range(0,self.window.active_view().size()): 
      s += self.window.active_view().substr(x) 
     newFile = self.window.new_file() 
     newFile.run_command("test",{"textBuffer": s}) 

class Test(sublime_plugin.TextCommand): 
    def run(self, edit, textBuffer): 
     self.view.insert(edit, 0, textBuffer) 

あなたがそうするより良い/より簡単な方法を知っていますか?
ありがとうございます!

答えて

20

あなたはと、現在のドキュメントの内容を取得することができます:

contents = self.view.substr(sublime.Region(0, self.view.size())) 
関連する問題