VSCode:如何让 Ctrl+k 杀到行尾? [英] VSCode: how to make Ctrl+k kill till the end of line?

查看:31
本文介绍了VSCode:如何让 Ctrl+k 杀到行尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio Code 中,Ctrl-k 快捷键绑定到 清除终端.

我在 Windows 中将 bash 配置为我的终端,并希望它像传统的 Emacs 键绑定一样工作,也就是说,让它杀死行尾.

我已尝试在用户设置中禁用此配置的默认键绑定,但没有奏效:

commandsToSkipShell":[workbench.action.terminal.clear"]

如何让终端服从我训练了20年的肌肉记忆?

解决方案

如果您对 Unix shell 有多年的记忆,并且想要阻止 VSCode 捕获您的键盘快捷键,请关闭 allowChords.在较新的 VSCode 版本中,您只需打开 File ->首选项 ->用户(选项卡),搜索 allowChords 并取消选中它.

或者你可以编辑你的 %APPDATA%\Code\User\settings.json 文件并输入:

 terminal.integrated.allowChords":false

现在很多命令都可以工作了:

  • Ctrl+K 杀到行尾,
  • Ctrl-Y 从上方粘贴被杀死的行
  • Ctrl+R 在您的历史记录中搜索您的命令,
  • 和 Ctrl+A 转到行首

我在这个线程中有另一个答案,但我认为这是一个更好的解决方案.这是文档.>

如果您只想修复 Ctrl-K 行为,请参阅其他答案.

In Visual Studio Code, the Ctrl-k shortcut is bound to clearing the terminal.

I've configured bash as my terminal in Windows and would like it to behave as the traditional Emacs key bindings, that is, to make it kill the end of the line.

I've tried to disable the default key binding with this configuration in the user settings, but it didn't work:

"commandsToSkipShell": [
        "workbench.action.terminal.clear"
      ]

How to make the terminal obey my 20 years trained muscle memory?

解决方案

If you have years of muscle memory of Unix shell and want to prevent VSCode to capture your keyboard shortcuts, turn off allowChords. In newer VSCode version you can simply open File -> Preferences -> User (tab), search for allowChords and uncheck it.

Or you can edit your %APPDATA%\Code\User\settings.json file and put this:

   "terminal.integrated.allowChords": false

Now a lot of commands will just work:

  • Ctrl+K for killing till the end of the line,
  • Ctrl-Y pastes the killed line from above
  • Ctrl+R searches for your commands in your history,
  • and Ctrl+A goes to the beginning of the line

I have another answer in this thread, but I think this is a better solution. Here is the documentation.

See other answers if you want to fix just the Ctrl-K behavior.

这篇关于VSCode:如何让 Ctrl+k 杀到行尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆