你好,欢迎进入江苏优软数字科技有限公司官网!

诚信、勤奋、创新、卓越

友好定价、专业客服支持、正版软件一站式服务提供

13262879759

工作日:9:00-22:00

Mac电脑安装Sublime Text指南

发布时间:2023-06-06

浏览次数:0

sublime text教程_sublime text使用教程_sublime text使用教程

【前言】

之前推荐过DevC++安装教程(链接附在文末)。 不幸的是,只有一个版本的 DevC++。 如果您使用的是 Mac 笔记本,则需要使用其他软件。 本文将介绍如何在Mac笔记本上安装Text软件并配置C++编译环境。

Text 是一个轻量级的文本编辑器,支持多种语言的句子高亮和代码补全。 具有高度的可扩展性和 Vim 模式。 Text具有漂亮的用户界面和强大的功能,例如代码缩略图、插件、代码片段等。Text是一个跨平台的编辑器,支持Linux、等操作系统。 本文只介绍Mac系统的安装步骤。 想在系统下安装的朋友可以上网查相关手册。

【教程】

1个

安装文本

到官网下载Text安装包

sublime text教程_sublime text使用教程_sublime text使用教程

找到下载好的安装包,双击解压

解压后看到【Text.app】,将其拖入应用程序中,然后双击打开

sublime text使用教程_sublime text使用教程_sublime text教程

打开后会有提示,选择【打开】

sublime text教程_sublime text使用教程_sublime text使用教程

打开后,进入Text的空白页面。

sublime text教程_sublime text使用教程_sublime text使用教程

2个

安装 C++ 编译器

在空白页面,先保存文件,确定文件名和存放位置。

sublime text使用教程_sublime text使用教程_sublime text教程

注意文件名要加上“.cpp”后缀! 然后点击【保存】保存。

sublime text教程_sublime text使用教程_sublime text使用教程

保存后编译代码。

#include using namespace std;
int main(){ cout << "OK" << endl; return 0;}

sublime text教程_sublime text使用教程_sublime text使用教程

编译运行,使用快捷键[+B],选择C++File-Run

sublime text使用教程_sublime text使用教程_sublime text教程

弹出窗口,选择【确定】

sublime text教程_sublime text使用教程_sublime text使用教程

提示安装sublime text使用教程,选择【】

sublime text使用教程_sublime text教程_sublime text使用教程

选择【同意】

sublime text使用教程_sublime text教程_sublime text使用教程

等待安装...

sublime text使用教程_sublime text教程_sublime text使用教程

安装完成

sublime text使用教程_sublime text使用教程_sublime text教程

再次使用快捷键[+B]编译运行,可以看到下方弹出运行结果。

注意使用这种编译方式很难进行输入交互,所以需要继续配置C++终端才能运行。

sublime text使用教程_sublime text教程_sublime text使用教程

3个

配置C++终端运行

点击【工具】->【构建】->【新建】

sublime text使用教程_sublime text教程_sublime text使用教程

将以下代码复制粘贴到软件中

(也可以打开此网址获取)

{    "cmd":    [        "bash",        "-c",        "g++ '${file}' -std=c++11 -stdlib=libc++ -o '${file_path}/${file_base_name}'"    ],    "file_regex": "^(..{FNXX==XXFN}*):([0-9]+):?([0-9]+)?:? (.*)$",    "working_dir": "${file_path}",    "selector": "source.c, source.c++",    "variants":    [        {            "name": "Run",            "cmd":            [                "bash",                "-c",                "g++ '${file}' -std=c++11 -stdlib=libc++ -o '${file_path}/${file_base_name}' && open -a Terminal.app '${file_path}/${file_base_name}'"            ]        }    ]}

sublime text使用教程_sublime text使用教程_sublime text教程

使用快捷键【+S】保存文件,编辑文件名为【C++.-bulid】

sublime text使用教程_sublime text使用教程_sublime text教程

保存后关闭文件,返回【apple.cpp】文件sublime text使用教程,使用快捷键【+Shift+B】编译运行,选择【C++-Run】。

注意,使用[+B]会默认为之前编译运行的选项,如果需要修改,使用[+Shift+B];

如果需要终端操作,选择【C++-Run】;

如果需要文件输入输出,选择【C++File-Run】。

sublime text教程_sublime text使用教程_sublime text使用教程

sublime text使用教程_sublime text教程_sublime text使用教程

4个

编译器

新节目

选择【文件】->【新建文件】,快捷方式为【+N】

sublime text使用教程_sublime text使用教程_sublime text教程

*注意:

新建的文件需要先保存,后缀名要加“.cpp”,并设置保存位置

快捷键【+S】

sublime text使用教程_sublime text教程_sublime text使用教程

sublime text使用教程_sublime text使用教程_sublime text教程

保存并开始编程! 一定要先保存! 一定要加上.cpp后缀!

5个

其他

Text还有丰富的插件,个性化设置让你的编程如虎添翼! 有兴趣的朋友可以在熟悉软件后上网搜索相关资料进行配置! 以后我们会分享更多编程工具的使用方法!

.

sublime text使用教程_sublime text使用教程_sublime text教程

如有侵权请联系删除!

13262879759

微信二维码