Sublime Text 2-based MinGW-C + + configuration file

Source: Internet
Author: User
Tags sublime text



Previously, according to the online method in the Sunlime text 2 configuration of C/C + + development environment, but each time in the menu to switch to a different compilation configuration, and I feel very troublesome, tossing the next, their personal preferences on the configuration file made a few changes, the final result is as follows:






Shortcut key Description:



Run:



The result is displayed in the bottom text bar: Ctrl +,



The results are displayed in the cmd window: Ctrl +.



C:



Compile: Ctrl + Shift + B



Compile and run (show results in the bottom text bar): Ctrl + Shift +,



Compile and run (display the results in a CMD window): Ctrl + Shift +.



C++:



Compiling: Ctrl + B



Compile and run (show results in the bottom text bar): Ctrl + Alt +,



Compile and run (display the results in a CMD window): Ctrl + Alt +.






Compile the configuration file: Menu-to-Tools-build system--New build system ...



If the ConverToUTF8 plugin is not installed, follow the instructions in the note to modify it (line 6th)



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"]
          }
     ]
}





Shortcut profile: 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-based MinGW-C + + configuration file


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.