If you use column selection often in Visual Studio Code, you may find the default shortcut keys combination is a bit too much. By default, to make a column selection or multiple lines in the same horizontal cursor position, you need to press CTRL-SHIFT-ALT and either UP or DOWN arrow depending on the direction of your selections.
Fortunately, you can always assign your own shortcut keys for virtually any functions in this powerful code editor.
So here are the steps to do so.
-
From the top menu, select File -> Preferences -> Keyboard Shortcuts (or press a combination of CTRL-K CTRL-S) to open the Keyboard Shortcuts windows.
-
Within Keyboard Shorcuts window, look for the following:
cursorColumnSelectDown cursorColumnSelectUp cursorColumnSelectPageDown cursorColumnSelectPageUp
-
Right-click and select Change Keybinding (CTRL-K CTRL-K) and press the key combination you want to use and press ENTER to save it or ESCAPE to cancel. In this example, I use a keyboard combination SHIFT-ALT-ARROW. Repeat this step for each operation.
-
Once completed, you should see something similar to the screenshot below in your Keyboard Shortcuts window.
That’s it.
If you want to see the configuration in JSON format, you can click on the active link keybindings.json on the top of the Keyboard Shortcuts window (For advanced customizations open and edit keybindings.json), then you’ll see the JavaScript Object Notation that looks similar to the following:
// Place your key bindings in this file to overwrite the defaults [ { "key": "shift+alt+down", "command": "cursorColumnSelectDown", "when": "editorTextFocus" }, { "key": "ctrl+shift+alt+down", "command": "-cursorColumnSelectDown", "when": "editorTextFocus" }, { "key": "shift+alt+up", "command": "cursorColumnSelectUp", "when": "editorTextFocus" }, { "key": "ctrl+shift+alt+up", "command": "-cursorColumnSelectUp", "when": "editorTextFocus" }, { "key": "shift+alt+pagedown", "command": "cursorColumnSelectPageDown", "when": "editorTextFocus" }, { "key": "ctrl+shift+alt+pagedown", "command": "-cursorColumnSelectPageDown", "when": "editorTextFocus" }, { "key": "shift+alt+pageup", "command": "cursorColumnSelectPageUp", "when": "editorTextFocus" }, { "key": "ctrl+shift+alt+pageup", "command": "-cursorColumnSelectPageUp", "when": "editorTextFocus" } ]
As indicated on the top banner of Keyboard Shortcuts window, as an advanced user, can always go straight to the keybindings.json and modify the keyboard shortcuts in the json file directly.
Related Articles
How to Make Visual Studio Code Colorize Classic ASP Code
How to Reassign Column Selection Shortcut Keys in Sublime Text
How to Open Visual Studio Code from command line macOS
How to Add Comma to Each Line Using Visual Studio Code or Sublime Text
Further Reading
Key Bindings for Visual Studio Code
Leave a Reply