新建的编译环境中的内容是这样的:
指令变量的意义分别是:只编译、只运行、项目结构中编译以及运行、项目中只编译只运行等,这里的encoding不是sublime的编辑环境的encoding
{ "cmd": ["g++", "${file}", "-std=c++11", "-o", "${file_path}\\${file_base_name}", "&", "start", "cmd", "/c", "${file_path}\\${file_base_name} & echo. & pause"], "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", "working_dir": "${file_path}", "selector": "source.c, source.c++", "shell": true, "encoding":"GBK", "variants": [ { "name" : "BuildOnly", "cmd":["g++", "${file}", "-std=c++11", "-o", "${file_path}\\${file_base_name}"] }, { "name" : "RunOnly", "cmd" : ["start", "cmd", "/c", "${file_path}\\${file_base_name} & echo. & pause"] // "cmd": ["cmd", "/c", "g++", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & echo.&pause"] }, { "name" : "PipeBuildandRun", "cmd":["g++", "${file}", "-std=c++11", "-o", "${file_path}\\${file_base_name}","&","${file_path}\\${file_base_name}", "<","${file_path}\\in",">","${file_path}\\out"] }, { "name" : "PipeRunOnly", "cmd" : ["${file_base_name}", "<","in",">","out"] }, { "name" : "ProjectBuild&Run", "cmd" : ["g++", "${file_path}\\*.cpp", "-std=c++11", "-o", "${file_path}\\project", "&", "start", "cmd", "/c", "${file_path}\\project & echo. & pause"] }, { "name" : "ProjectBuildOnly", "cmd" : ["g++", "${file_path}\\*.cpp", "-std=c++11", "-o", "${file_path}\\project"] }, { "name" : "ProjectRunOnly", "cmd" : ["start", "cmd", "/c", "${file_path}\\project & echo. & pause"] } ] }
设置用户快捷键:
{ "keys": ["f9"], "command": "build"},
通过F9进行Build+Run,在这之前注意保存cpp文件。
如果想要文件的编码是GBK就必须在创建的时候选中导航栏中的设置文件编码为GBK,注意必须在文件创建的时候操作,否则输出至控制台的中文字符是会显示乱码的,
windows控制台的编码默认的是GBK