Visual Studio Code snippet as keyboard shortcut key

前端 未结 2 1820
梦如初夏
梦如初夏 2020-12-24 03:03

I know how to modify and create code snippets and I know how to modify shortcut keys, but how does one bring those 2 together?

2条回答
  •  没有蜡笔的小新
    2020-12-24 04:05

    It would seem that, as of version 1.9, Visual Studio Code can do what you are looking for, no other extensions necessary.

    From https://code.visualstudio.com/updates/v1_9#_insert-snippets

    "You can now bind your favorite snippets to key bindings. A sample that encloses a selection with single quotes looks like this:"

    Add the snippet below to keybindings.json (open Keyboard Shortcuts editor and click on the For advanced customizations open and edit keybindings.json link)

    {
        "key": "cmd+k",
        "command": "editor.action.insertSnippet",
        "args": { "snippet": "'$TM_SELECTED_TEXT'" }
    }
    

提交回复
热议问题