Sublime Forum

Opening the compiled program in an external console

#1

Hi everybody !

I discovered Sublime Text 3 or 4 days ago and I’m totally in love with it :smile:. I’m using it for C++ programming right now, which is not always a piece of cake (it took me 3 or 4 hours to get the build config working).

The Sublime Text console doesn’t seem to support input methods (a loop with an input will never end), so I wanted to open my compiled programs (small programs, with no graphical library) in an external console.

I tried everything in the build config (using “cmd”, “call”, etc.) but the program still opens in Sublime Text’s console, thus crashing the software (as I get an infinite loop).

I’ve seen a solution to that proble that consist in defining an alternative input method that works on Sublime Text. I’d prefer to avoid that as I want to stay as generic as possible and not use editor-specific code.

Thank you in advance !

EDIT:

Here’s my .sublime-build config:

{ "cmd": "C:\\MinGW\\bin\\mingw32-g++.exe", "-Wall", "-time", "$file", "-o", "$file_base_name"], "file_regex": "^ ]*File \"(...*?)\", line ([0-9]*)", "working_dir": "${project_path:${folder}}", "selector": "source.c", "shell": true, "encoding": "latin1" }

0 Likes

Running c++ on windows in ST2
#2

UP !

Can anyone help please? I still can’t fix this.

1 Like

#3

UP (again, yeah, sorry).

Can anyone help me with this please? This is really ruining my experience with Sublime Text 2 !

0 Likes

#4

This works form me with CoffeeScript - open external cmd windows with running program, so for c/cpp this should be like this:

{
  "cmd": 
    "start","cmd", "/K" , "C:\\MinGW\\bin\\mingw32-g++.exe", "-Wall", "-time", "$file", "-o", "$file_base_name"
  ],
  "selector": "source.c",
  "shell": true
}

This exactly only compile in external window. So, for running you can do something like this:

"cmd": "start","cmd", "/K" , "$file_base_name"]

Using variants:

{
  "cmd": 
    "start","cmd", "/K" , "g++", "-Wall", "-time", "$file", "-o", "$file_base_name"
  ],
  "selector": "source.cpp",
  "shell": true,
  "variants":
    
        {
            "name": "Run",
            "cmd": "start","cmd", "/K" , "$file_base_name"]
        }
    ]
}

Ctrl + B - build
Ctrl + Shift + B - run in external

Compiling in ST2 and running in external window:

{
  "cmd": 
    "g++", "-Wall", "-time", "$file", "-o", "$file_base_name", "&&", "start","cmd", "/K" , "$file_base_name"
  ],
  "selector": "source.cpp",
  "shell": true
}

Ctrl + B - build and run

http://img52.imageshack.us/img52/3339/20120813155748.png

0 Likes