mac sublime text C/C++
- Click
Tools
->Build System
->Build New System
- Then enter the following configuration:
{
"cmd": ["bash", "-c", "g++ '${file}' -std=c++11 -stdlib=libc++ -o '${file_path}/${file_base_name}'"],
"file_regex": "^(..{FNXX==XXFN}*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ '${file}' -std=c++11 -stdlib=libc++ -o '${file_path}/${file_base_name}' && open -a Terminal.app '${file_path}/${file_base_name}'"]
}
]
}
- Then press
Command+S
save and nameC/C++.sublime-build
, the nameC/C++
you just play, but the extension and save the path will not change, the default on the line
This configuration file will be saved in
/Users/用户名/Library/Application Support/Sublime Text 3/Packages/User
case
- Then you can now write c / c ++ code, and then finished, click
Tools
->Build System
->C:C++
Note that, because I just saved when the file name
C/C++
, which/
is automatically replaced:
, and allC:C++
that is, I just saved configuration file
- After the compiler finished selecting, press
Command+B
, and then chooseC:C++ - Run
to run, the next pressCommand+B
can run