如何在vscode设置自定义功能快捷键

如何在vscode设置快捷键

实现行尾或行首自动添加指定字符

1.下载扩展 macro

在setting添加以下内容

"macros": {
    "end_semicolon": [ // 末尾加分号
        "cursorLineEnd",
        {
            "command": "type",
            "args": {
                "text": ";"
            }
        },
    ],
    "start_greatersign": [ // 行首加>
        "cursorLineStart",
        { "command": "type",
            "args": {
                "text": ">"
            }
        },
    ],
}

打开文件->首选项->键盘快捷方式

点击

如何在vscode设置自定义功能快捷键

进入键位json配置
添加如下内容

    {
        "key": "alt+;",
        "command": "macros.end_semicolon"   
    },
    {
        "key": "alt+.",
        "command": "macros.start_greatersign"
    },

完成 使用键位alt+;和alt+.可以分别在行尾加分号 行首加大于号(便于Markdown引用)