Sublime text 3 - 编译程序并在终端运行 [英] Sublime text 3 - compile program and run in terminal
问题描述
我使用Ubuntu 12.04,我想知道,是否可以从终端自动运行c ++程序?它真的很糟糕,当你必须使用生成在控制台,因为有时我无意中使无限循环,并必须重新启动升级文本再工作。
我使用Sublime text 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 ++和做。 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}\""
}
]
}
要使用它,请转到工具 - >构建系统
并选择 C ++
。您现在可以使用 Ctrl B 运行构建(top命令)或 Ctrl Shift B 运行运行
变体。
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 - 编译程序并在终端运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!