1.下載sublime text3
官網地址:http://www.sublimetext.com/3
ubuntu直接在Ubuntu Software中搜索sublime安裝
2.配置環境變量(windows)
下載Mingw放到C盤,path路徑設為`C:\MinGW\bin`
在cmd中輸入`g++ -v`或`gcc -v`判斷路徑是否設置成功,path路徑在電腦重啟后生效
3.設置package control
在控制台中加入一下網址的代碼
https://packagecontrol.io/installation
4.配置編譯運行文件
在windows下的編譯配置文件(支持c++11)
{
"encoding": "cp936",
"working_dir": "$file_path",
"shell_cmd": "g++ -Wall -std=c++11 -fexec-charset=GBK $file_name -o $file_base_name",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"selector": "source.c++",
"variants":
[
{
"name": "Run",
"shell_cmd": "g++ -Wall -fexec-charset=utf-8 \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
}
]
}
用c編譯的話只需用
gcc替換上述代碼的g++即可`
在ubuntu下的編譯配置文件(支持c++11)
{
"shell_cmd": "g++ '-std=c++11' '${file}' -o '${file_path}/${file_base_name}'",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Build & Run",
"shell_cmd": "x-terminal-emulator -e bash -c \"g++ '-std=c++11' '${file}' -o '${file_path}/${file_base_name}' ; '${file_path}/${file_base_name}' ; read -p '\nPress ENTER or type command to continue...'\""
},
{
"name": "Build Only",
"shell_cmd": "g++ '-std=c++11' '${file}' -o '${file_path}/${file_base_name}'"
},
{
"name": "Run Only",
"shell_cmd": "x-terminal-emulator -e bash -c \"'${file_path}/${file_base_name}' ; read -p '\nPress ENTER or type command to continue...'\""
}
]
}
5.參考
https://www.cnblogs.com/kearon/p/7354888.html
