如何在 Visual Studio 代码中打开 shell 命令提示符?

How to open a shell command prompt inside Visual Studio Code?

当使用Visual Studio代码时,我如何运行命令行程序,例如choco(巧克力)命令?我是否需要在 VS Code 之外有一个单独的命令行 (CMD.exe) 运行ning,或者代码中是否有一个 hotkey/window 我可以 运行 这些命令?

我看到了“命令面板”,但不完全清楚该面板中的命令引擎运行。

使用CMD+Shift+CCTRL+Shift+C但它打开外部编辑器标准bash控制台。

我希望他们会实施集成控制台

正如 MCBL 所写,没有 集成控制台 。您可以在此处为该功能投票:UserVoice - Integrated terminal <-- dead link.

第 3 方编辑

Uservoice 不再使用,上面的 link 已死。 integrated terminal might be this one.

的功能请求

由于调试控制台不支持需要从控制台读取输入的程序,您可以通过在启动配置中将属性 externalConsole 设置为 true 来启用外部本地控制台。 lauch.json 只写:"externalConsole" : true

对于集成控制台,使用Ctrl+`

来自发行说明:

With the May release, we are rolling out the initial version of an integrated terminal. You can open the terminal using Ctrl+`, from the View | Toggle Integrated Terminal menu, or from the View > Toggle Integrated Terminal command in the Command Palette.

https://code.visualstudio.com/updates#_workbench

@brady321 的回答仅适用于美式键盘:

Note: The following keys are rendered assuming a standard US keyboard layout.(https://code.visualstudio.com/Docs/customization/keybindings)

例如,英国键盘使用 Ctrl+':

您可以在 File > Preferences > Keyboard Shortcuts 搜索 workbench.action.terminal.toggleTerminal 中找到您的快捷方式。如果您使用的不是美式键盘,它会显示使用您的键盘布局的等效快捷方式:

要查看打开本机控制台的快捷方式,请尝试在快捷方式文件中找到 workbench.action.terminal.openNativeConsole

More information about integrated terminal at: https://code.visualstudio.com/docs/editor/integrated-terminal

我使用了自定义快捷方式。将下面的键绑定添加到 keybinds.json:

[
    {
        "key": "ctrl+,",
        "command": "workbench.action.terminal.toggleTerminal"
    }
]

打开keybinds.json

CTRL + SHIFT + P 然后键入 键盘 并单击 打开键盘快捷键

可以用这个菜单选项打开它:View > Integrated Terminal

集成终端的默认键盘快捷键是Ctrl+`

在vscode中您可以使用多个集成终端。
如果你想打开另一个使用 Ctrl+Shift+`

vscode 呈现快捷键 假定标准美式键盘布局 。如果您使用不同的键盘布局,please read how 可以看到您当前键盘的表现形式。 很简单,打开这个菜单选项:File > Preferences > Keyboard Shortcuts 并在 Default Keyboard Shortcut 上搜索命令 workbench.action.terminal.toggleTerminal 然后将鼠标指向信息图标即可看到组合。对我来说是 Ctrl+ñ 因为我使用的是西班牙语键盘布局。

创建个人快捷方式以切换到终端也很酷。打开此菜单选项:File > Preferences > Keyboard Shortcuts 并在 keybinding.json 选项卡上输入:

[
    {
        "key": "ctrl+pageup",
        "command": "workbench.action.terminal.focusNext",
        "when": "terminalFocus"
    },{
        "key": "ctrl+pagedown",
        "command": "workbench.action.terminal.focusPrevious",
        "when": "terminalFocus"
    }
]

现在当光标聚焦在终端上,并且有多个终端时,您可以使用 Ctrl+Page Down[ 组合浏览每个终端=51=] 用于上一个终端,Ctrl+Page Up 用于下一个终端。

提示:如果您专注于编辑器,可以使用相同的键盘快捷键在选项卡中导航。

相反,您也可以 运行 您的 visual studio 代码工具中的一个终端,只需执行以下操作即可:

转到“查看 > 集成终端”或使用快捷键“Ctrl + '”

我相信这在更高版本的 visual studio 代码中可用。我可以在版本 1.7.0-insider 上执行此操作。

Ctrl+ `

Integrated Terminal In Visual Studio Code, you can open an integrated terminal, initially starting at the root of your workspace. This can be very convenient as you don't have to switch windows or alter the state of an existing terminal to perform a quick command line task.

To open the terminal:

我正在使用 vsCode 1.9.1。据我所知有两种方法

  1. 您可以通过按 Ctrl + ` 键轻松打开它。
  2. 转到查看->集成终端,如下图

在我的英国 MacBook 上,当我查看 VS 代码的键盘快捷方式(代码 > 首选项 > 键盘快捷方式)时,切换集成终端具有键绑定 Crtl+`.

但是,该快捷方式适用于 Ctrl+§,这是我 MacBook 上与 ` 在英国 Windows 键盘上。

可以拿微软的文本编辑器,不能拿etc等等

运行 命令行程序的最佳方式是使用 VS Code 中提供的终端 window。这种方式不会切换任何应用程序。但是要在终端和其他 windows 之间切换,我建议如下:

  1. 打开终端 - Ctrl + `
  2. 打开第二个终端 - 当你在第一个终端中运行安装节点脚本并且它被阻止并且你需要运行同时执行第二个脚本 - Ctrl + Shift + `
  3. 到 focus/switch 回到终端而不重新打开:
    1. F1 然后键入 键盘快捷键
    2. 找到workbench.action.terminal.focus并设置为Ctrl + \ - 这个斜杠通常位于右 Ctrl 键旁边。这使得代码和终端之间的切换非常容易,因为 Ctrl + `Ctrl + \ 用右手和食指调用。

在 ubuntu

中使用 Ctrl + J 键进行测试

将集成终端切换为CMD

  1. 打开综合终端Ctrl + `
  2. 如果 Bash 终端在您想要 命令提示符 (cmd) 时打开,只需 运行 命令:cmd,在终端切换到命令提示符.

测试一下,这对我有用

Ctrl + ñ

Ctrl + `

ctrl + j

还有 MAC 的 Ctrl+Shift+

我希望你换成定制的。
通过 Command+Shift+P 打开 Command Palette

键入“键盘快捷键...” - Select Preferences: Open Keyboard Shortcuts

.
请参阅 Terminal: Create New Integrated Terminal 选项。双击它以将其更改为自定义。

转到 File > Preferences > Keyboard Shortcuts 或使用快捷键 Ctrl+K Ctrl+ S.

要在键绑定中搜索的类型:workbench.action.terminal.new

双击快捷键并添加你想要的快捷方式Super+T在默认配置中未使用) .

For mac Cmd + j
对于赢 Ctrl + j