I know I can change the line-numbering in Visual Studio Code to relative by adding the line "editor.lineNumbers": "relative", to the settings.json file, but I am looking for a way to bind it to a keybinding such that I can toggle between absolute (on) and relative (relative). I've messed with keybindings, but I can't find a command that can temporarily change settings. 
I'd prefer to be able to have one key that toggles it between the two, but if there had to be a key to turn it to absolute and another to turn it to relative that would be fine.
Using the extension Settings Cycler, you can toggle between on and relative using a keyboard shortcut by inserting the following entry in your keybindings.json file:
{
    "key": "ctrl+l",
    "command": "settings.cycle",
    "when": "editorTextFocus",
    "args": {
        "id": "relativeLineNumbers",
        "values": [
            {
                "editor.lineNumbers": "on"
            },
            {
                "editor.lineNumbers": "relative"
            }
        ]
    }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With