1.安装MinGW
具体方法见我的另一篇博客MinGW安装配置
2.Create New Build System
- 打开sublime text
- Tools—Build System—New Build System
用以下代码覆盖新建的文件的内容
{
"cmd": ["g++","-Wall", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"encoding":"cp936",
"variants":
[
{
"name": "Run",
"cmd": ["cmd", "/c", "g++", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "cmd", "/c", "${file_path}/${file_base_name}"]
},
{
"name": "RunInCommand",
"cmd": ["cmd", "/c", "g++", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & echo.&pause"]
}
]
}
按Ctrl+s键保存
可以更改自己喜欢的名字
我这里之前改成 c.sublime-build
完成后重启sublime text
3.开始使用
编写一段简单的c/c++代码
重新进入build system 选择之前命名的东西 我命名的是 c 所以选 c
选好后ctrl+shift+b就可以运行了
第三个是在外部中断运行
当然,如果你觉得按快捷键加点击的方式有点麻烦
那么你可以进入Preferences—Key Buildings
还是将下面的东西覆盖原来的
[
{"keys": ["f11"], "command": "build", "args": {"variant": "RunInCommand"}}
]
我这里设置的是f11,你按照你的喜好来配置
弄好后保存重启
按f11就可以快速运行了
版权声明:本文为weixin_45485719原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。