How to run programs in an external console with Sublime Text in Windows system?(如何在 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 的终端)中打开我编译的程序.我尝试使用call"或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"
}
诀窍是使用start"命令执行生成的文件,该命令强制文件在新的 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 在外部控制台中运行程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Windows 系统中使用 Sublime Text 在外部控制台中运行程序?


- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- C++ 协变模板 2021-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 从python回调到c++的选项 2022-11-16
- STL 中有 dereference_iterator 吗? 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01