簡體   English   中英

vscode中一個鍵盤快捷鍵的多個操作

[英]Multiple actions on one keyboard shortcut in vscode

是否可以將多個操作分配給 Visual Studio 代碼中的一個鍵盤快捷鍵?

例如:將 cursor 向上移動 x 3 設置為“ctrl + w”

提前致謝。

可以使用像Commands這樣的擴展

settings.json

"commands.commands": {
    "down3": {
        "sequence": [
            "cursorDown",
            "cursorDown",
            "cursorDown",
        ],
    },
},

keybindings.json

{
    "key": "ctrl+w",
    "command": "down3",
},

或者只使用keybindings.json

{
    "key": "ctrl+w",
    "command": "commands.run",
    "args": [
        "cursorDown",
        "cursorDown",
        "cursorDown"
    ]
},

支持像鍵綁定這樣的宏的功能請求#871


雖然,對於這個特定的例子,最好使用built-in命令(以避免任何跳躍):

{
    "key": "ctrl+w",
    "command": "cursorMove",
    "args": {
        "to": "down",
        "by": "line",
        "value": 3
    }
}

https://code.visualstudio.com/api/references/commands

對於正在尋找答案的其他人,請學習制作自己的 VS 代碼擴展。 大約花了一個小時,我能夠制作執行多個命令的各種快捷方式。 vs 代碼站點有很好的資源: https : //code.visualstudio.com/docs/extensions/overview

我使用宏擴展( https://marketplace.visualstudio.com/items?itemName=geddski.macros ):

在 settings.json 中:

"macros": {
    "showGit": ["workbench.view.scm", "git-graph.view"]
}

然后在 keybindings.json 中:

{
    "key": "ctrl+shift+g",
    "command": "showGit"
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM