[md]首先最近在用sublime这款软件但其环境配置着实麻烦不得已就全部看了一遍,也是一篇总结,在此分享给论坛的友友们希望能帮到你(第一次发帖,不足之处还请指正谢谢大家,如有违规请直接删帖), 以下出现的.sublime-build文件都可以通过packageresourcesviewer这个插件来实现,安装后在命令面板输入open resouce回车打开你要配置的语言即可,或者仿照下面go语言的方法做
下不了这个插件的我把文件打包的链接扔在这了,下载:https://wwi.lanzoui.com/i2Rdapmferi 密码:52pj解压后放入自己资源包的文件中就可以用了
一切基于自己的编译环境配置好的情况下(也就是可以在命令行时使用的情况下)
c/c++
在csingle.sublime-build或者c++.sublime-build中更改配置如下,一般改一个就行了这个要装mingw且配置好环境变量,具体自行百度
{
"cmd": ["g++", "${file}", "-std=c++11", "-o", "${file_path}\\\\${file_base_name}", "&", "start", "cmd", "/c", "${file_path}\\\\${file_base_name} & echo. & pause"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}",
"selector": "source.c, source.c++", "shell": true,
"encoding":"cp936",
"variants":
[
{
"name" : "Build Only",
"cmd":["g++", "${file}", "-std=c++11", "-o", "${file_path}\\\\${file_base_name}"]
},
{
"name" : "Run Only",
"cmd" : ["start", "cmd", "/c", "${file_path}\\\\${file_base_name} & echo. & pause"]
},
{
"name" : "Pipe Build and Run",
"cmd":["g++", "${file}", "-std=c++11", "-o", "${file_path}\\\\${file_base_name}","&","${file_path}\\\\${file_base_name}", "<","${file_path}\\\\in",">","${file_path}\\\\out"]
},
{
"name" : "Pipe Run Only",
"cmd" : ["${file_base_name}", "<","in",">","out"]
},
{
"name" : "Project Build & Run",
"cmd" : ["g++", "${file_path}\\\\*.cpp", "-std=c++11", "-o", "${file_path}/${file_base_name}", "&", "start", "cmd", "/c", "${file_path}/${file_base_name} & echo. & pause"]
},
{
"name" : "Project Build Only",
"cmd" : ["g++", "${file_path}\\\\*.cpp", "-std=c++11", "-o", "${file_path}/${file_base_name}"]
},
{
"name" : "Project Run Only",
"cmd" : ["start", "cmd", "/c", "${file_path}/${file_base_name} & echo. & pause"]
}
]
}
javac
javac.sublime-build
{
"shell_cmd": "runJava.bat \"$file\"",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
"encoding": "utf-8"
}
其中runjava.bat应配置文件如下,记得放到自己的jdk的bin目录下
@ECHO OFF
cd %~dp1
ECHO Compiling %~nx1.......
IF EXIST %~n1.class (
DEL %~n1.class
)
javac %~nx1
IF EXIST %~n1.class (
ECHO -----------OUTPUT-----------
java %~n1
)
Go
这个自己在自己安装的sublime路径下\Data\Packages中创建一个文件夹,而后在该文件中创建一个Go.sublime-build文件
Go.sublime-build内容
{
"cmd": ["go", "run", "$file_name"],
"file_regex": "^[ ]*File \"(…*?)\", line ([0-9]*)",
"working_dir": "$file_path",
"selector": "source.go"
}
bash
这个需要装linux子系统,在设置中启用适用于linux的windows子系统而后在shellscript.sublime-build中改为如下配置
{
"cmd" : ["bash", "-c", "bash ${file_name}"],
"shell": true,
"working_dir": "${file_path}",
}
python
在python.sublime-build文件中改为
{
"cmd": ["python","-u","$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"shell":"true",
"encoding":"cp936"
}