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 - 编译程序并在终端中运行
基础教程推荐
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
