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】+",",即可实现自动输入逗号或分号并回车。

相关推荐
古月居GYH2 小时前
【数据分析】如何在PyCharm中高效配置和使用SQL
ide·sql·pycharm
死也不注释5 小时前
【Unity 编辑器工具开发:GUILayout 与 EditorGUILayout 对比分析】
unity·编辑器·游戏引擎
lyj1689975 小时前
vue-i18n+vscode+vue 多语言使用
前端·vue.js·vscode
这是个栗子8 小时前
【问题解决】VSCode终端中看不到Git-Bash
ide·git·vscode
岁月玲珑11 小时前
【使用Android Studio调试手机app时候手机老掉线问题】
android·ide·android studio
许白掰15 小时前
Linux入门篇学习——Linux 帮助手册
linux·运维·服务器·嵌入式硬件·学习·编辑器·vim
木头没有瓜16 小时前
vscode离线安装插件
ide·vue.js·vscode
lls23318 小时前
恢复idea文件目录
ide
NeRF_er19 小时前
使用 VScode Debug加不上断点的原因
ide·vscode·编辑器
GHL28427109019 小时前
error MSB8041: 此项目需要 MFC 库。从 Visual Studio 安装程序(单个组件选项卡)为正在使用的任何工具集和体系结构安装它们。
ide·visual studio