Jumping Lines in V.S. Code
V.S. Code Keyboard Shortcuts
V.S. Code offers its users the ability to customize Keyboard Shortcuts using navigational type commands that move the cursor, via the "keybindings.json" configuration file. When the "keybindings.json" file is configured properly you are able to use Keyboard Shortcuts to jump up n-lines, jump down n-lines, jump left n-chars, or to jump right n-chars.
- NOTE: "
n can equal any number".
Getting Started
To navigate the cursor in the fashoin that this topic covers, you will need to configure a few customized V.S. Code Keybindings (aka Keyboard Shortcuts). If this is not somthing that you have done before you don't need to worry. Binding a shortcut to a unique combonation of keys is actually quite simple, and it can be whimsical as well. It certainly will improve your V.S. Code experiance.
To get started creating your "line-jumping" Keyboard Shortcuts follow the instructions below. If you need any extra help during the keybinding creation process you can use the official V.S. Code, community maintained, documentation as a guide. I have posted the link below:
– Use the F1 Key to open your "Quick Input Drop-Down Menu"
– Type "Keyboard Shortcut" into the "Quick Input Menu".
– Select "Open Keyboard Shortcuts (JSON)"
Note: There will be two "Keyboard Shortcut" options that you will be able to choose from. One of the options will read default, and one WILL NOT read default. Make sure to select the one that DOES NOT read default. If you are unfamiliar with keybindings, and have never created one before then the file should be totally empty.
Once inside of the keybindings.json file, add the following "JSON" block to the file
// "keybindings.json"
{
{
"key": "ctrl+1",
"when": "editorTextFocus",
"command": "cursorMove",
"args": {
"by": "line",
"to": "down",
"value": 1
}
},
{
"key": "ctrl+2",
"when": "editorTextFocus",
"command": "cursorMove",
"args": {
"by": "line",
"to": "down",
"value": 5
}
},
{
"key": "ctrl+3",
"when": "editorTextFocus",
"command": "cursorMove",
"args": {
"by": "line",
"to": "down",
"value": 10
}
},
{
"key": "ctrl+shift+1",
"when": "editorTextFocus",
"command": "cursorMove",
"args": {
"by": "line",
"to": "up",
"value": 1
}
},
{
"key": "ctrl+shift+2",
"when": "editorTextFocus",
"command": "cursorMove",
"args": {
"by": "line",
"to": "up",
"value": 5
}
},
{
"key": "ctrl+shift+3",
"when": "editorTextFocus",
"command": "cursorMove",
"args": {
"by": "line",
"to": "up",
"value": 10
}
},
}
"The above is only for testing purposes, as the keybindings are simple, and override default VSCode keybindings. You will have to decide which keybindings work best for you, however; if you add the above to your "keybindings.json" file you will get the following Keyboard Shortcuts"
Jump Down a Line CTRL+1
Jump Down 5 Lines CTRL+2
Jump Down 10 Lines CTRL+3
Jump Up a Line CTRL+SHIFT+1
Jump Up 5 Lines CTRL+SHIFT+2
Jump Up 10 Lines CTRL+SHIFT+3
For More Help:
For further assistance Visit the VSCode Commands Page to a list of all commands, or to read specifically about the cursorMove command @:
...or to read about keybindings visit keybindings page that is included the opensource community maintained VSCode documentation collection @: