一、调用cmd运行c(首先复制MinGW到C盘根目录,并添加环境变量)
Tools --> Build System --> New Build System
删除所有内容
复制如下代码进去,保存为 C.sublime-build
{
"working_dir": "$file_path",
"cmd": "gcc -Wall \"filename\"−o\"filename\"−o\"file_base_name\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c",
"variants":
[
{
"name": "Run",
"shell_cmd": "gcc -Wall \"file\"−o\"file\"−o\"file_base_name\" && start cmd /c \"\"filepath/filepath/{file_base_name}\" & pause\""
}
]
}
4.Ctrl + Shift + B, 选择 “C",编译源文件
5.Ctrl + Shift + B, 选择 “C-run",调用cmd运行c程序
二、调用cmd运行java(首先要安装好JDK并配置环境变量)
Tools --> Build System --> New Build System
删除所有内容
复制如下代码进去,保存为 java.sublime-build
{
"cmd": ["javac","-d",".","$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.java",
"encoding":"cp936",
//执行完上面的命令就结束
// 下面的命令需要按Ctrl+Shift+b来运行
"variants":
[
{
"name": "run",
"shell": true,
"cmd" : ["start","cmd","/c", "java ${file_base_name} &echo. & pause"],
//c是执行完命令后关闭cmd窗口,
// /k是执行完命令后不关闭cmd窗口。
// echo. 相当于输入一个回车
// pause命令使cmd窗口按任意键后才关闭
"working_dir": "${file_path}",
"encoding":"cp936"
}
]
}
4.Ctrl + Shift + B, 选择 “java",编译java源文件
5.Ctrl + Shift + B, 选择 “java-run",运行java程序
三、调用cmd运行python
Tools --> Build System --> New Build System
删除所有内容
复制如下代码进去,保存为 Python.sublime-build
{
"cmd": ["python","-u","$file"],
"selector": "source.python",
"file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)",
"env": {"PYTHONIOENCODING": "utf-8"},
//执行完上面的命令就结束
// 下面的命令需要按Ctrl+Shift+b来运行
"variants":
[
{
"name":"Run",
"shell": true,
"cmd": ["start","cmd","/c", "python $file &echo. & pause"],
//c是执行完命令后关闭cmd窗口,
// /k是执行完命令后不关闭cmd窗口。
// echo. 相当于输入一个回车
// pause命令使cmd窗口按任意键后才关闭
"working_dir": "${file_path}",
}
]
}
4. Ctrl + Shift + B, 选择 “Python-Run"
四、调用cmd运行Batch File
Tools --> Build System --> New Build System
删除所有内容
复制如下代码进去,保存为 Batch File.sublime-build
{
"cmd": ["$file"],
"file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)",
"file_patterns": ["*.bat"], //一定要加上这行,build system才能自动匹配 *.bat 文件。
//执行完上面的命令就结束
// 下面的命令需要按Ctrl+Shift+b来运行
"variants":
[
{
"name":"Run",
"shell": true,
"cmd": ["start","cmd","/c", " $file &echo. & pause"],
"working_dir": "${file_path}",
}
]
}
4. Ctrl + Shift + B, 选择 “Batch File-Run"
转载至:https://www.cnblogs.com/sublime/p/8420702.html