Define Keybinding to insert special character in VSCode

Viewed 2180

I would like to define a keybinding to insert a specific unicode character in VSCode. What is the right way to achieve this ?

2 Answers

VSCode has a type command to handle exactly this kind of use case:

In keybindings.json:

{
    "key": "ctrl+alt+1 s",
    "command": "type",
    "args": {
        "text": "Ψ"
    }
}

Type and select "Preferences: Open Keyboard Shortcuts (JSON)" in the Ctrl+Shift+P menu in VSCode.

The file is called keybindings.json but it doesn't seem to be indexed quite as such in search for some reason.

Related