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.
相关文章