Debian11下SublimeText3配置C语言环境
1、新建C语言编译系统
依次打开:工具==>编译系统==>新编译系统(Tools->Build System->New build System),输入一下内容1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25{
"shell_cmd": "gcc '${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 \"gcc '${file}' -o '${file_path}/${file_base_name}' -lm; '${file_path}/${file_base_name}' ; read -p '\nPress ENTER or type command to continue...'\""
// "shell_cmd": "g++ '${file}' -o '${file_path}/${file_base_name}'; '${file_path}/${file_base_name}'" // 不打开终端直接输出结果
},
{
"name": "Build Only",
"shell_cmd": "gcc '${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...'\""
}
]
}
2、设置快捷键
依次点击:首选项==>快捷键设置 ==> 用户(Preferences->Key Buildings -> User)
添加以下内容:(一键编译并运行)1
2
3
4
5
6
7
8{
"keys": ["f9"],
"command": "build",
"args":
{
"variant": "Build & Run"
}
},
不设置快捷键,直接ctrl+b也可以输出。
3、格式化插件coolformat
CoolFormat:简单好用的代码格式化工具,相当于简化版的Astyle,
快捷键ctrl+shift+p==>install package安装
默认操作快捷键:ctrl+alt+shift+q格式化当前文件ctrl+alt+shift+s格式化当前选中。
参考:
1、Ubuntu / Debian / Deepin等 Sublime Text 3 配置C++环境(一键编译&运行,格式化代码
2、使用SublimeTemp自定义C文件模板