I have been using Visual Studio since last 4 years for all sort of learning and development works.
Now, that I have moved my focus a bit towards node.js and switched to Microsoft's Visual Studio Code, I feel a bit of uneasiness at times due to different shortcut keys.
Visual Studio Code, provides us a feature that we can change the shortcut keys as per our preference and that is the scope of this blog.
In Visual Studio, the shortcut for Code Formatting is Ctrl+k Ctrl+D but in Visual Studio Code, it's Shift+Alt+F.
Let's try and change it to Ctrl+k Ctrl+D
Step 1: In your Visual Studio Code windows, go to File->Preferences->Keyboard Shortcuts
This will open two files beside each other like in the screenshot below:
Step 2: Now, on the window on the right i.e. the keybindings.json file, you can define your own shortcut in the below format:
-
- [ {
- "key": "ctrl+k ctrl+d", "command":"editor.action.format"
-
- }
- ]
In the above code, we have defined that the set of keys,
Ctrl+k Ctrl+D will fulfill the command of formatting the code in the code editor.
Now both the commands, Ctrl+K Ctrl+D and Shift+Alt+F works as code format keys in Visual Studio Code.
Hope this blog, helped in making coding on Visual Studio Code easier.