从菜单中,选择 Build -> New build system ... 并复制粘贴:
视窗
仅编译:
{
"cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe", "-lm", "-Wall"],
"selector" : "source.c",
"shell":true,
"working_dir" : "$file_path"
}
编译并运行:
{
"windows":
{
"cmd": ["cc","-std=c99" ,"$file_name","-o", "${file_base_name}.exe", "-lm", "-Wall", "&","start", "${file_base_name}.exe"]
},
"selector" : "source.c",
"shell": true,
"working_dir" : "$file_path",
}
Linux
仅编译:
{
"cmd" : ["gcc", "$file_name", "-o", "${file_base_name}", "-lm", "-Wall"],
"selector" : "source.c",
"shell":false,
"working_dir" : "$file_path"
}
编译并运行:
{
"linux":
{
"cmd": ["cc","-std=c99" ,"$file_name","-o", "${file_base_name}", "-lm", "-Wall", ";", "./${file_base_name}"]
},
"selector" : "source.c",
"shell": true,
"working_dir" : "$file_path",
}
并使用扩展名 *.sublime-build 保存它
ST 只是一个编辑器,因此您不能将其用作输入流,您必须使用 bash、zsh 等 shell 来执行此操作。