Sublime text 3 - 编译程序并在终端中运行

Sublime text 3 - compile program and run in terminal(Sublime text 3 - 编译程序并在终端中运行)
本文介绍了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 - 编译程序并在终端中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

What do compilers do with compile-time branching?(编译器如何处理编译时分支?)
Can I use if (pointer) instead of if (pointer != NULL)?(我可以使用 if (pointer) 而不是 if (pointer != NULL) 吗?)
Checking for NULL pointer in C/C++(在 C/C++ 中检查空指针)
Math-like chaining of the comparison operator - as in, quot;if ( (5lt;jlt;=1) )quot;(比较运算符的数学式链接-如“if((5<j<=1)))
Difference between quot;if constexpr()quot; Vs quot;if()quot;(“if constexpr()之间的区别与“if())
C++, variable declaration in #39;if#39; expression(C++,if 表达式中的变量声明)