Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
279 views
Welcome To Ask or Share your Answers For Others

1 Answer

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}""
        }
    ]
}

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...