問題描述
我使用的是 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 - 編譯程序并在終端中運行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!