【VScode】vscode设置快捷键控制光标移动(替代上下左右)

2021年9月11日 2点热度 0条评论 来源: 石头的小软

文章目录

1.设置双快捷键控制光标上下移动

通过设置双快捷键来控制光标的上下移动,解放你的双手,全程不使用鼠标

  1. 打开快捷键设置:

如图片所示操作或者使用快捷键[ctrl+s]

  1. 例如改光标向右移动的快捷键,搜索“right”,找到“cursorRight”选项改为你设置的快捷键组合[Alt+k],如图所示

这里设置了快捷键组合之后,原有的上下左右键则失效。

3.设置上下左右键和快捷组合同时控制光标移动

打开json格式设置快捷键:

command前有“-”则该快捷键失效,将“-”去掉则重新生效;

  1. 其他的方向键可参考上述方法;

    我的设置json文件如下

    功能 键盘操作
    光标上移 ↑/{alt+u}
    光标下移 ↓/{alt+j}
    光标左移 ←/{alt+h}
    光标右移 →/{alt+k}
    光标回到代码行首 Home/{alt+y}
    光标回到代码行末 End/{alt+i}
// Place your key bindings in this file to override the defaultsauto[]
[
  { 
    "key": "alt+u",
    "command": "cursorUp",
    "when": "textInputFocus"
  },
  { 
    "key": "up",
    "command": "cursorUp",
    "when": "textInputFocus"
  },
  { 
    "key": "alt+u",
    "command": "selectPrevSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  { 
    "key": "up",
    "command": "selectPrevSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  { 
    "key": "alt+j",
    "command": "cursorDown",
    "when": "textInputFocus"
  },
  { 
    "key": "down",
    "command": "cursorDown",
    "when": "textInputFocus"
  },
  { 
    "key": "alt+j",
    "command": "selectNextSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  { 
    "key": "down",
    "command": "-selectNextSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  { 
    "key": "alt+k",
    "command": "cursorRight",
    "when": "textInputFocus"
  },
  { 
    "key": "right",
    "command": "cursorRight",
    "when": "textInputFocus"
  },
  { 
    "key": "alt+h",
    "command": "cursorLeft",
    "when": "textInputFocus"
  },
  { 
    "key": "left",
    "command": "cursorLeft",
    "when": "textInputFocus"
  },
  { 
    "key": "alt+i",
    "command": "cursorEnd",
    "when": "textInputFocus"
  },
  { 
    "key": "end",
    "command": "cursorEnd",
    "when": "textInputFocus"
  },
  { 
    "key": "alt+y",
    "command": "cursorHome",
    "when": "textInputFocus"
  },
  { 
    "key": "home",
    "command": "cursorHome",
    "when": "textInputFocus"
  }
]

1.1参考引用:

参考以下博客

vs Code设置双快捷键

    原文作者:石头的小软
    原文地址: https://blog.csdn.net/weixin_42158546/article/details/112463296
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。