如何在带有Sublime

如何在带有Sublime

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

问题描述

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



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



我想在外部控制台(例如Window的终端)中打开我的编译程序。
我试图使用call或c​​md,但不能使它的工作。 (它仍然在控制台中打开文件)



这是我的生成配置:

  {
cmd:[C:\\MinGW\\bin\\mingw32-g ++。exe,-Wall,-time,$文件,$,$ file],
file_regex: (... *?)\,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}} :source.c,
shell:true,
encoding:latin1
}

诀窍是使用start命令执行生成的文件,强制文件在新的cmd窗口中打开,并将所有内容放在第一个cmd定义中&&为了执行这两个命令),因为如果你定义多个cmd数组,它们会覆盖。


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

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

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)

Here's my build configuration:

{
"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"
}
解决方案

Try with this:

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

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.

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

08-13 11:00