Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically change line-numbering settings in Visual Studio Code

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.

like image 289
Testare Avatar asked Apr 24 '17 20:04

Testare


1 Answers

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"
            }
        ]
    }
}
like image 114
Félix Caron Avatar answered Sep 28 '22 17:09

Félix Caron