Visual Studio代码 - 终端(PowerShell) - 如何复制文本

atr*_*eon 4 visual-studio-code

如何在终端中复制文本?

(我尝试过Ctrl + C,但是在终端中产生了^ c.右击似乎粘贴了我剪贴板中的任何内容.)

"terminal.integrated.rightClickCopyPaste":true - 将此覆盖为false

小智 11

要在 PowerShell Visual Studio 中复制消息,只需选择该消息并右键单击它,它就会自动复制。

  • 好吧,这很愚蠢。为什么这是默认行为? (2认同)

Egg*_*gon 8

上面的解决方案对我不起作用。对于任何寻找答案的人:当前在 VS 代码终端中复制和粘贴绑定到ctrl+insertshift+insert


Mar*_*ark 7

我不知道你正在使用哪个版本的Visual Studio Code,但是这个用户设置有一段时间(可能是一年;我可能是错的):

// A set of command IDs whose keybindings will not be sent to the shell and instead always be handled by Code. This allows the use of keybindings that would normally be consumed by the shell to act the same as when the terminal is not focused, for example Ctrl + P to launch Quick Open.
  "terminal.integrated.commandsToSkipShell": [

     "workbench.action.terminal.copySelection",
     "workbench.action.terminal.paste",
  ],
Run Code Online (Sandbox Code Playgroud)

那里有更多的命令.我只是展示你感兴趣的那些.默认情况下,那些复制/粘贴命令已经存在.

如果我禁用copySelection命令,我会看到你看到的行为.因此,您可能需要将Visual Studio代码更新为较新版本,或确保上述设置确实出现在您的用户设置中.正如我所说的那样默认情况下对我而言,但也许有些事情发生了变化.

[编辑于2018年2月]:

Visual Studio Code 1.20添加了自动复制到剪贴板的设置,无论您在终端中选择了什么.请参阅选择副本.

复制选择

现在,无论何时在终端中选择文本,您都可以自动复制:

" terminal.integrated.copyOnSelection ":true

默认情况下禁用此功能.

因此,仅选择任何文本将其复制到剪贴板.