gpt4 book ai didi

c++ - SublimeText C++ 防止在生成时运行

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:43:30 24 4
gpt4 key购买 nike

我在 macOS 上使用 SublimeText-3 进行 C++ 编程,试图利用构建功能。

在这种情况下,我希望(仅)通过执行 Cmd+B 来构建我的程序。 Cmd+Shift+B 将运行它。

但是当我按下 Cmd+B 时,构建和运行都发生了。

C++ Single File.sublime-build 的内容如下:

{
"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++ -std=c++14 \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
}
]
}

有什么奇怪的吗?

如何将构建和运行拆分为不同的命令?

一些引用:Sublime text 3 - compile program and run in terminal

在 Preferences - Key Bindings 我看到:

{ "keys": ["f7"], "command": "build" },
{ "keys": ["super+b"], "command": "build" },
{ "keys": ["super+shift+b"], "command": "build", "args": {"select": true} },

我觉得还可以

最佳答案

您检查过您的按键绑定(bind)了吗?他们可能以某种方式被分配给同一个键。在 Preferences - Key Bindings 中,您应该会看到您的设置。我不是 Mac 用户,但你的 C++ 构建文件看起来不错。键绑定(bind)中的build设置应如下所示:

{ "keys": ["ctrl+b"], "command": "build" },
{ "keys": ["ctrl+shift+b"], "command": "build", "args": {"select": true} }

不要忘记将 ctrl 更改为您在 mac 上的任何内容。

关于c++ - SublimeText C++ 防止在生成时运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44217653/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com