标签:
之前按照网上的方法在 sunlime text 2 中配置了 C/C++ 开发环境,但是每次在菜单切换C和C++不同的编译配置,感觉很麻烦,折腾了下,自己按照个人喜好对配置文件做了点改动,最后结果如下:
快捷键说明:
运行:
在底部文本栏显示结果:Ctrl + ,
在cmd窗口中显示结果:Ctrl + .
C:
编译:Ctrl + Shift + B
编译并运行(在底部文本栏显示结果):Ctrl + Shift + ,
编译并运行(在cmd窗口中显示结果):Ctrl + Shift + .
C++:
编译:Ctrl + B
编译并运行(在底部文本栏显示结果):Ctrl + Alt + ,
编译并运行(在cmd窗口中显示结果):Ctrl + Alt + .
编译配置文件: Menu --> Tools --> Build System --> New Build System...
如果未安装ConverToUTF8插件,请按照注释中的说明修改(第6行)
MinGW64-11.sublime-build :
{ "cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}", "-Wall", "-std=c++11"], "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}", "selector": "source.c, source.c++", "encoding": "GBK", //If you haven`t install ConvertToUTF8, please install it or delete/comment this line or use "encoding": "utf-8", "shell": true, "variants": [ { //Shortcut: Ctrl+Shift+B "name": "Run", //Build C "cmd": ["gcc", "${file}", "-o", "${file_path}/${file_base_name}", "-Wall", "-std=c11"] }, { //Shortcut: Ctrl+, "name": "RunLocal", //Run in bottom text box "cmd": ["${file_path}/${file_base_name}"] }, { //Shortcut: Ctrl+. "name": "RunCmd", //Run in cmd window "cmd": [ "start", "CMD", "/C", "${file_path}/${file_base_name} & pause"] }, { ////Shortcut: Ctrl+Shift+, "name": "BuildCAndRunLocal", //Build C & run in bottom text box "cmd": ["CMD", "/C", "gcc ${file} -o ${file_path}/${file_base_name} -Wall -std=c11 & ${file_path}/${file_base_name}.exe"] }, { //Shortcut: Ctrl+Shift+. "name": "BuildCAndRunCmd", //Build C & run in cmd window "cmd": ["start", "CMD", "/C", "@echo off & gcc ${file} -o ${file_path}/${file_base_name} -Wall -std=c11 & @echo on & ${file_path}/${file_base_name}.exe & pause"] }, { //Shortcut: Ctrl+Alt+, "name": "BuildCppAndRunLocal", //Build C++ & run in bottom text box "cmd": ["CMD", "/C", "g++ ${file} -o ${file_path}/${file_base_name} -Wall -std=c++11 & ${file_path}/${file_base_name}.exe"] }, { //Shortcut: Ctrl+Alt+. "name": "BuildCppAndRunCmd", //Build C++ & run in cmd window "cmd": ["start", "CMD", "/C", "@echo off & g++ ${file} -o ${file_path}/${file_base_name} -Wall -std=c++11 & @echo on & ${file_path}/${file_base_name}.exe & pause"] } ] }
快捷键配置文件:Menu --> Preferences --> Key Bindings - User
Default (Windows).sublime-keymap :
[ { "keys": ["ctrl+0"], "command": "build", "args": {"variant": "BuildC" } }, { "keys": ["ctrl+,"], "command": "build", "args": {"variant": "RunLocal" } }, { "keys": ["ctrl+."], "command": "build", "args": {"variant": "RunCmd" } }, { "keys": ["ctrl+shift+,"], "command": "build", "args": {"variant": "BuildCAndRunLocal" } }, { "keys": ["ctrl+shift+."], "command": "build", "args": {"variant": "BuildCAndRunCmd" } }, { "keys": ["ctrl+alt+,"], "command": "build", "args": {"variant": "BuildCppAndRunLocal" } }, { "keys": ["ctrl+alt+."], "command": "build", "args": {"variant": "BuildCppAndRunCmd" } } ]
sublime text 2 基于 MinGW 的 C/C++ 配置文件
标签:
原文地址:http://www.cnblogs.com/dawn-l/p/5169101.html