Sublime text 3 - compile program and run in terminal(Sublime text 3 - 编译程序并在终端中运行)
问题描述
我使用的是 Ubuntu 12.04,我想知道是否可以从终端自动运行 C++ 程序?当您必须在控制台中使用构建时,这真的很糟糕,因为有时我会意外地进行无限循环,并且必须重新启动 sublime text 才能再次工作.我正在使用 Sublime 文本 3.
I am using Ubuntu 12.04, and I was wondering, is it possible to automatically run c++ program from terminal? It really sucks when you have to use build in console because sometimes I make infinite loops by accident and have to restart sublime text to work again. I am using Sublime text 3.
推荐答案
Sublime Text 3 包括两个您可能感兴趣的构建系统:C++ 和 Make.C++.sublime-build 文件如下:
Sublime Text 3 includes two build systems you might be interested in: C++ and Make. The C++.sublime-build file is as follows:
{
"shell_cmd": "g++ "${file}" -o "${file_path}/${file_base_name}"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"shell_cmd": "g++ "${file}" -o "${file_path}/${file_base_name}" && "${file_path}/${file_base_name}""
}
]
}
要使用它,请转到 Tools ->Build System 并选择C++.您现在可以使用 CtrlB 运行构建(顶部命令),或 CtrlShiftB 运行 Run 变体.
To use it, go to Tools -> Build System and select C++. You can now use CtrlB to run the build (top command), or CtrlShiftB to run the Run variant.
这篇关于Sublime text 3 - 编译程序并在终端中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Sublime text 3 - 编译程序并在终端中运行
基础教程推荐
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 常量变量在标题中不起作用 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
