Last active
December 10, 2015 02:58
-
-
Save devlights/4371567 to your computer and use it in GitHub Desktop.
GitHubにアップしているMySampleCodeプロジェクトのコードをSublime Text 2から実行するためのプラグイン。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"keys": ["ctrl+alt+j"], | |
"command": "run_sample" | |
}, | |
{ | |
"keys": ["ctrl+alt+k"], | |
"command": "run_js_sample" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
import os | |
import subprocess | |
class RunJsSampleCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
subprocess.Popen(["cmd", "/k", "node " + self.view.file_name()], cwd=os.path.split(self.view.file_name())[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
import os | |
import subprocess | |
class RunSampleCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
className = self.view.substr(self.view.sel()[0]) | |
subprocess.Popen(["cmd", "/k", "msbuild /p:TargetClass=" + className], cwd=os.path.split(self.view.file_name())[0]) |
Author
devlights
commented
Dec 25, 2012
- Tools -> New Pluginから新しいプラグインが作成できる
- sublime, sublime_pluginをインポート
- RunSampleCommandのようなクラス名をつける。キャメルの部分を小文字にしてアンダーバーで繋いだものがコマンドになる
- RunSampleCommand -> run_sample
- runメソッドを定義して、処理を記述.
- TextCommandクラスを継承しておくと、内部でViewにアクセスできる (self.view)
- Viewから選択範囲を取得するには、 self.view.substr(self.view.sel()[0]) とする
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment