Over a million developers have joined DZone.

Setting Custom Shortcuts in Visual Studio Code

How to take advantage of customizing your keyboard shortcuts in Visual Studio Code.

· Web Dev Zone

Make the transition to Node.js if you are a Java, PHP, Rails or .NET developer with these resources to help jumpstart your Node.js knowledge plus pick up some development tips.  Brought to you in partnership with IBM.

I have been using Visual Studio for the last 4 years for all sorts of learning and development projects. 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 the different shortcut keys.

Visual Studio Code provides us a feature to can change the shortcut keys according to 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 Shortcut

Image title

This will open two files beside each other like in the screenshot below:

Image title

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: 

// Place your key bindings in this file to overwrite the defaults  
[ {  
    "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 work as code format keys in Visual Studio Code. 

Hope this article, helped in making coding with Visual Studio Code easier.

Learn why developers are gravitating towards Node and its ability to retain and leverage the skills of JavaScript developers and the ability to deliver projects faster than other languages can.  Brought to you in partnership with IBM.

nodejs ,visual studio code ,javascript

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}