如果是已經(jīng)支持的語言施禾,直接CTRL+B(CTRL+SHIFT+B)
如果暫不支持弥搞,就在頂部菜單
Tools--Build system--New build system
然后,出現(xiàn)語言編譯設置文件(以shell為例)斯碌,默認的內(nèi)容是:{ "shell_cmd": "make"}.修改為下面的內(nèi)容,保存為shell.sublime-bulid投慈。
{
"cmd": ["bash","$file"]
}
然后伪煤,Tools--Build system中選擇剛剛一種語言(shell ).再使用CTRL+B編譯執(zhí)行就行了。
但是职烧,這樣不能自動識別語言蚀之,每次都要手動選擇
改進:
{
"cmd": ["bash","$file"],
"file_regex": "shell$",
"selector": "source.shell"
}
如果你保存的語言編譯設置文件為A.sublime-build
就是
{
"cmd": ["bash","$file"],
"file_regex": "A$",
"selector": "source.A"
}
多選項十分必要足删,如選擇編譯锁右,執(zhí)行,還是檢查代碼
添加一個"variants"參數(shù)拂到,添加執(zhí)行py2码泞、py3浦夷,檢查py2、py3的選項
{
"cmd": "python3 -u \"$file\"",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"env":
{"PYTHONIOENCODING": "utf-8",
},
"variants":
[
{
"name": "Syntax Check(py2)",
"shell_cmd": "python -m py_compile \"${file}\"",
},
{
"name": "Syntax Check(py3)",
"shell_cmd": "python3 -m py_compile \"${file}\"",
},
{ "name": "Run py2",
"cmd": ["python2", "-u", "$file"]
},
{ "name": "Run py3",
"cmd": ["python3", "-u", "$file"]
},
{ "name": "List Python Files",
"cmd": ["ls -l *.py"],
"shell": true
},
{ "name": "Word Count (current file)",
"cmd": ["wc", "$file"]
},
{
"name":"py2 -> py3",
"cmd" :["python3","-m","lib2to3","-nw","-o","out","$file"]
},
{
"name":"編譯exe",
"cmd" :["pyinstaller","--console","--onefile","$file"]
}
]
}
如何修改sublime自帶的語言罐孝?
python就是軟件自帶支持的語言呐馆,要修改它,要么就新建一個算了莲兢。要么修改它內(nèi)部的Python.sublime-build
Python.sublime-build是直接找不到的汹来,可以通過PackageResourceViewer插件來找到內(nèi)部文件。
安裝插件方法自行百度改艇,安裝好后收班,Ctrl+Shift+P,輸入open
找到并進入PackageResourceViewer:Open Resource。
再輸入并進入python,找到并進入Python.sublime-build
然后就打開這個軟件內(nèi)部文件了谒兄。
推薦教程:
http://sublime-text.readthedocs.io/en/latest/reference/build_systems.html