在安装codeblocks-20.03mingw-setup, 添加系统环境变量path : C:\Program Files\CodeBlocks\MinGW\bin 之后,在sublime中, 打开 Preferences --> Browser packages 后,打开User目录,添加如下内容新文件,保存为gcc.sublime-build,就可以编译运行c.
{
"cmd": ["gcc","${file}","-o", "${file_path}/${file_base_name}"],
"file_regex":"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir":"${file_path}",
"selector": "source.c",
"encoding":"cp936",
"variants":
[
{
"name": "Run",
"cmd": ["cmd","/c", "gcc", "${file}", "-o", "${file_path}/${file_base_name}","&&", "cmd", "/c","${file_path}/${file_base_name}"]
},
{
"name":"RunInCommand",
"cmd": ["cmd","/c", "gcc", "${file}","-o","${file_path}/${file_base_name}", "&&","start", "cmd", "/c","${file_path}/${file_base_name} & pause"]
}
]
}
类似地,在安装go1.20.4.windows-amd64 设置环境变量后,添加新文件,内容如下保存为go.sublime-build,
{
"cmd": ["go", "run", "$file_name"],
"file_regex": "^[ ]*File \"(…*?)\", line ([0-9]*)",
"working_dir": "$file_path",
"selector": "source.go" ,
"variants":
[
{
"name": "Run",
"cmd": ["go", "run", "$file_name"]
}
]
}
打开Preferences --> key Bings, 添加如下配置
[
{"keys":["f5"], "command": "build", "args":{"variant": "Run"}},
{"keys":["f6"], "command": "build", "args":{"variant": "RunInCommand"}}
]
设置c / go的运行快捷键为F5。