git - VSCode如何添加用于暂存选定行的键盘快捷键

标签 git visual-studio-code git-stage

有一个Stage Selected Lines Git 的按钮,但是有没有办法为它添加键盘快捷键?
stage selected lines option
必须单击两次( three dots > Stage Selected Lines )太麻烦了。

最佳答案

如果有人还在寻找这个:
命令 stageSelectedRanges , unstageSelectedRanges , revertSelectedRanges前段时间已经介绍过了。请注意,当前有一个 related bug在 VSCode 中:diff View 在部分阶段后不会刷新 - 但除此之外它就像一个魅力。
这就是我在我的键绑定(bind)中设置它的方式:

{
  "key": "s",
  "command": "git.stageSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
},
{
  "key": "u",
  "command": "git.unstageSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
},
{
  "key": "r",
  "command": "git.revertSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
}

关于git - VSCode如何添加用于暂存选定行的键盘快捷键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38985239/

相关文章:

visual-studio-code - 带有 Python 扩展的 VSCode 2019 年 4 月 - "Python Extension Loading..."

git - 获取 "stage"的 Git 概念

git - 暂存删除的文件

git - 我如何找到哪个提交在 git 中引入了特定行?或者有更好的选择吗?

git - Jenkins Pipeline 与 Azure Web 应用程序部署

git config core.fileMode false 不适用于 redhat git 1.7.1

git - 无需编写 GIt 的别名

npm - 为什么每次我尝试输入我的发布者名称时,我的 npm 都说我需要查看它的用户权限?

visual-studio-code - VSCode : Open new terminal as part of task?

git - 如何强制 git 发出警告或添加新文件?