Visual Studio Code中实现移到行尾加分号或逗号并换行

最近因项目需要,IDE由Visual Studio 2022换成了Visual Studio Code,语言也由C#换成了Dart。总体感觉在逐渐适应中,不过还是有些小细节不吐不快。

比如在编码过程中,在下面这种情况,我们按下【tab】后,光标会自动移到行尾,我们直接回车就可以完成本行代码输入。

不愧是老牌IDE,对于这种录入小细节的便捷性处理还是很贴心的。

然而,在Visual Studio Code中,当录入代码时的光标还在小括号内,如果要想快速完成输入。要按下【end】+";",或者【end】+","才可以。如图:

我们希望按下快捷键,让光标自动移动到行尾,自动录入分号或逗号。

解决方案:

1.打开插件面板,找到multi-command,并安装。

2.按下【ctrl】+【shift】+P,输入keyboard,点击下面菜单:

3.在kedbindings.json的\[\]中输入

复制代码
{  
  "key": "ctrl+;",  
  "command": "extension.multiCommand.execute",  
  "args": {  
    "sequence": [  
      {  
        "command": "cursorEnd"  
      },  
      {  
        "command": "type",  
        "args": {  
          "text": ";"  
        }  
      },  
      {  
        "command": "editor.action.insertLineAfter"  
      }  
    ]  
  },  
  "when": "editorTextFocus"  
},  
{  
  "key": "ctrl+,",  
  "command": "extension.multiCommand.execute",  
  "args": {  
    "sequence": [  
      {  
        "command": "cursorEnd"  
      },  
      {  
        "command": "type",  
        "args": {  
          "text": ","  
        }  
      },  
      {  
        "command": "editor.action.insertLineAfter"  
      }  
    ]  
  },  
  "when": "editorTextFocus"  
}

4.【ctrl】+";"或【ctrl】+",",即可实现自动输入逗号或分号并回车。

相关推荐
2501_915909062 天前
移动端开发工具链怎么组合比较好,iOS、Android、跨端三套配置方案
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
weixin_464078072 天前
ppt转为draw.io方法
编辑器
sunoo-2292 天前
【ARM嵌入式学习笔记Day6】一文打通i.MX6ULL时钟体系:PLL/PFD/预分频+滞回比较器全解析
arm开发·笔记·vscode·单片机·imx6ull·汇编语言
明天…ling2 天前
gitee与vscode远程连接
vscode·gitee
2501_915918412 天前
iOS编程用什么软件好?主流工具Xcode、AppCode、CodeRunner与新兴快蝎对比
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
__pop_2 天前
VSCode Remote SSH 远程连接 glibc 高版本依赖问题
vscode
daxiangxm3 天前
【趣味休息】“围住小猫在线玩”-“困住小猫”,又回来了
数据结构·人工智能·vscode·github·php
星光开发者3 天前
基于Spring Boot的充电桩管理系统的设计与实现-计算机毕设【课程设计】57105
vue.js·spring boot·vscode·mysql·django·php·express
程序员允诺3 天前
内网/无网环境必备:VS Code Remote-SSH 离线包下载与手动部署教程
vscode
滕州市燕猫虎计算机科技工作室个体工商户3 天前
IDEA:Command line is too long
java·ide·intellij-idea