gpt4 book ai didi

powershell - Visual Studio Code - Ctrl+Backspace 在集成终端中不起作用

转载 作者:行者123 更新时间:2023-12-02 22:11:07 25 4
gpt4 key购买 nike

Visual Studio Code 的终端 (PowerShell) 中,我正在尝试点击 Ctrl+Backspace删除最后一个单词,但它只是添加 ^W到最后,任何想法如何解决这个问题?它在 PowerShell 中的 Visual Studio Code 之外运行良好。

最佳答案

ctrl+backspace以某种方式映射到 ctrl+w在 vscode 集成终端中(可能是一个 bug),现在我们需要设置 ctrl+w绑定(bind)显式删除单词。很奇怪吧?

Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord
请注意,这仅适用于当前终端 session 。

要使这种行为持续存在,您可以在配置文件 Microsoft.PowerShell_profile.ps1 中设置它。文件。如果您的 powershell 版本文件夹中不存在该文件,请创建该文件。
C:\Program Files\PowerShell\6\Microsoft.PowerShell_profile.ps1
写在顶部
if ($env:TERM_PROGRAM -eq "vscode") {
Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord
}

查看更多: Power up your PowerShell
键绑定(bind)引用:
https://docs.microsoft.com/en-gb/previous-versions/powershell/module/psreadline/Get-PSReadLineKeyHandler?view=powershell-5.0
https://docs.microsoft.com/en-gb/previous-versions/powershell/module/psreadline/set-psreadlinekeyhandler?view=powershell-5.0

关于powershell - Visual Studio Code - Ctrl+Backspace 在集成终端中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52806758/

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