简体   繁体   English

如何在Visual Studio Code中自动“在行尾添加分号并转到下一行”?

[英]How do you automate “add a semicolon at line end and go to next line ” in Visual Studio Code?

When using Visual Studio Code, we can use use the shortcut 'Shift+Enter' to start an new line below and go to the head of the new line. 使用Visual Studio Code时,我们可以使用快捷键“ Shift + Enter”在下面开始新行并转到新行的开头。

However, when coding in languages like Rust, C/C++ or Javascript whose statements end with a semicolon, ';', one may want there is a shortcut to add a semicolon at the end of current line before starting an new line. 但是,当使用诸如Rust,C / C ++或Javascript之类的语句结尾为分号“;”的语言进行编码时,可能希望有一种捷径在开始新行之前在当前行末添加分号。

Was wondering what are the shortcut or how to do that? 想知道快捷方式是什么或该怎么做?

For no-language-specific, one can use 'macros', please reference https://marketplace.visualstudio.com/items?itemName=geddski.macros . 对于特定于非语言的语言,可以使用“宏”,请参考https://marketplace.visualstudio.com/items?itemName=geddski.macros

Here are my settings: 1. the macro: 这是我的设置:1.宏:

 "macros": {
        "addSemiAndGoNext": [
            "cursorEnd",
            {"command": "type", "args": {"text": ";"}},
            "editor.action.insertLineAfter"
        ]
    }
  1. Shortkey used: Alt+; 使用的快捷Alt+;Alt+;

Hope it can be useful. 希望它会有用。 If there are other ways, welcome sharing~ 如果还有其他方法,欢迎分享〜

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM