VS Code 设置双快捷键(快速移动光标)
2024-10-19 22:28:31
本文已同步到https://www.aukocharlie.com/archives/vscode%E8%AE%BE%E7%BD%AE%E5%8F%8C%E5%BF%AB%E6%8D%B7%E9%94%AE
平时写代码会经常用到上下左右键,比如打出两个括号 () ,编辑完之后得按到右括号后面
难免有这样的场景需要在编辑代码的时候小范围地移动光标,笔者在别的ide的习惯是通过“alt + jkli”
来实现光标移动,网上搜VS Code快捷键设置基本只能找到改默认值的方法,而没有能设置 相同的操作同时有多个快捷键的方法
废话少说,进入正题
首先打开快捷键设置
录制按键,按下“右键”,来查找相关快捷键,箭头所指为要找的(编辑时的光标移动)
右键更改键绑定,改为 alt+l
,若冲突,可以视情况把冲突的快捷键改成别的(比如已经存在alt+l
,则把它改为ctrl+alt+l
)
更改完之后,点击右上角的以JSON格式打开,会打开keybinding.json
文件
会形成类似这样的json
原来的right
键的command前面加上了-
号来"消除"此快捷方式,那么同理,去掉这个负号就可以“生效”了
去掉后发现就可以实现同样的快捷操作可以有多种快捷键
其他方向键类似,读者可以自行实现
最后附上我的keybinding.json
// 将键绑定放在此文件中以覆盖默认值auto[]
[
{
"key": "alt+i",
"command": "cursorUp",
"when": "textInputFocus"
},
{
"key": "up",
"command": "cursorUp",
"when": "textInputFocus"
},
{
"key": "alt+k",
"command": "cursorDown",
"when": "textInputFocus"
},
{
"key": "down",
"command": "cursorDown",
"when": "textInputFocus"
},
{
"key": "alt+j",
"command": "cursorLeft",
"when": "textInputFocus"
},
{
"key": "left",
"command": "cursorLeft",
"when": "textInputFocus"
},
{
"key": "alt+l",
"command": "cursorRight",
"when": "textInputFocus"
},
{
"key": "right",
"command": "cursorRight",
"when": "textInputFocus"
},
{
"key": "down",
"command": "list.focusDown",
"when": "listFocus && !inputFocus"
},
{
"key": "down",
"command": "selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "alt+k",
"command": "selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "up",
"command": "selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "alt+i",
"command": "selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
]
最新文章
- K-means聚类算法
- timus_1007_bfs
- linux平台下防火墙iptables原理(转)
- OutputFormat中OutputCommitter解析
- sql快速生成大量数据
- pytesser图片文本识别
- 屏蔽webbrowser控件右键的一种方法
- JavaScript简单的一些....
- 从On-Premise本地到On-Cloud云上运维的演进
- linux基础16-bash编程(case语句及脚本选项 )
- C#使用List实现类似RadioButtonGroup的单选功能
- java web项目由http转换成https遇到的各种坑
- 修改hosts文件用来观看coursera视频
- Linux - 多窗口管理器Screen程序
- JAVA OCR图片识别
- 【JEECG技术文档】数据权限自定义SQL表达式用法说明
- rviz1
- 开机自启动nginx,php-fpm
- Spark2 ML包之决策树分类Decision tree classifier详细解说
- svn+apache快速安装