Home 键转到 Visual Studio Code 中的行首?

问题描述 投票:0回答:3

Visual Studio Code 中使 Home 键转到行首的选项在哪里?

现在你必须做

首页首页

主页Ctrl+向左箭头

我希望 home 位于队列的开头。

奖金喋喋不休

文件→首选项→键盘快捷键:

奖励阅读

visual-studio-code keyboard-shortcuts
3个回答
3
投票
  1. 转到(Windows)文件->首选项->键盘快捷键
  2. 在搜索中输入cursorHome并右键单击->删除
    cursorHome
    cursorHomeSelect
  3. 上的按键绑定
  4. 在搜索中输入cursorLineStart,右键单击
    cursorLineStart
    ,然后 点击添加快捷方式然后按Home然后输入
  5. cursorLineStartSelect
    执行相同操作,但按 Shift-Home

1
投票

我认为没有任何内置选项可以更改 Home 的当前行为,但您可以借助宏扩展轻松地自行更改它,例如 multi-command (在

keybindings.json
中):

{
  "key": "home",
  "command": "extension.multiCommand.execute",
  "args": {
    "sequence": [
      "cursorHome",
      "cursorHome"
    ]
  },
  "when": "editorTextFocus"
}

现在按一次Home与按两次效果相同。


更简洁的方法是给出命令

cursorLineStart
Home 键绑定:

  {
    "key": "home",
    "command": "cursorLineStart",
    "when": "editorTextFocus"
  },

可以从按键绑定快捷方式执行此操作,也可以手动将其添加到您的

keybindings.json


0
投票

基于@Mark的答案,这是我的“keybindings.json”文件,它更改了 home / end 键的行为,以在按下 home 或 end 键时转到行的开头或结尾。这模拟了 ubuntu 中 vscode 的行为。

[
  {
    "key": "home",
    "command": "cursorLineStart",
    "when": "editorTextFocus"
  },
  {
    "key": "end",
    "command": "cursorLineEnd",
    "when": "editorTextFocus"
  },
]
© www.soinside.com 2019 - 2024. All rights reserved.