如何在Windows系统中使用Sublime Text在外部控制台中运行程序? [英] How to run programs in an external console with Sublime Text in Windows system?

查看:255
本文介绍了如何在Windows系统中使用Sublime Text在外部控制台中运行程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法为C ++配置了Sublime Text 2,现在可以编译代码了(使用MinGW编译器).

I managed to configure Sublime Text 2 for C++ and I can now compile my code (using the MinGW compiler).

不幸的是,Sublime Text控制台不支持C ++的任何输入.

Unfortunately, the Sublime Text console can't support any kind of input for C++.

我想在外部控制台(例如Window的终端)中打开我的编译程序. 我尝试使用通话"或"cmd",但无法使其正常工作. (它仍会在控制台中打开文件)

I want to open my compiled program in an external console (Window's terminal for instance). I tried to use "call" or "cmd" but couldn't make it work. (it still opens the file in the console)

这是我的构建配置:

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

推荐答案

尝试一下:

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

诀窍是使用开始"命令执行生成的文件,该命令将强制文件在新的cmd窗口中打开,并将所有内容放入第一个cmd定义(使用&&以便执行这两个命令),因为如果定义多个cmd数组,它们将被覆盖.

The trick is to execute the generated file using the "start" command, which forces the file to open in a new cmd window, and to put everything inside the first cmd definition (using the && in order to execute the two commands), because if you define more than one cmd array, they overwrite.

这篇关于如何在Windows系统中使用Sublime Text在外部控制台中运行程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆