sublime配置c语言
时间: 2024-05-06 10:20:19 浏览: 143
1. 安装Sublime Text编辑器,下载地址:https://www.sublimetext.com/3
2. 安装Package Control插件,下载地址:https://packagecontrol.io/installation
打开Sublime Text编辑器,按下Ctrl + `键(菜单栏 -> View -> Show Console),输入以下代码,按下回车键即可安装Package Control插件:
```
import urllib.request,os,hashlib; h = '5f4cc3b6bdb69a5f8b25b3cd6ca3d761' + 'e3d0afc7d436eba6bea834f03e7fa115'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
```
3. 安装C语言插件,打开Sublime Text编辑器,按下Ctrl + Shift + P键(菜单栏 -> Tools -> Command Palette),输入install package,选择Package Control: Install Package,输入C++,选择C++11,安装即可。
4. 配置编译环境,打开Sublime Text编辑器,按下Ctrl + Shift + B键(菜单栏 -> Tools -> Build System -> New Build System),输入以下代码:
```
{
"cmd": ["gcc", "$file_name", "-o", "${file_base_name}.exe", "&&", "start", "cmd", "/k", "${file_base_name}.exe"],
"selector": "source.c",
"shell": true,
"working_dir": "${file_path}"
}
```
保存为C++.sublime-build。
5. 新建C语言文件,按下Ctrl + N键,输入以下代码:
```
#include <stdio.h>
int main()
{
printf("Hello, world!\n");
return 0;
}
```
6. 编译运行,按下Ctrl + B键即可编译运行C语言程序。
阅读全文