For Fedora
- Click
File
-> Preferences
-> Keyboard shortcuts
.
- Under
Default Keyboard Shortcuts
, search (Ctrl + F) for editor.action.format
.
Mine read "key": "ctrl+shift+i"
You can change it as well. Refer to this answer on how to... or if you are feeling a little lazy to scroll up:
You can add a keybinding in "Preferences->Keyboard shortcuts"
{ "key": "cmd+k cmd+d", "command": "editor.action.format" }
Or Visual Studio like:
{ "key": "ctrl+k ctrl+d", "command": "editor.action.format" }
Please note: cmd key is only for Macs. For Windows and Fedora (Windows keyboard) use Ctrl
EDIT:
As per Visual Code version 1.28.2
this is what I found.
editor.action.format
no longer exists. It has now been replaced by editor.action.formatDocument
and editor.action.formatSelection
.
Type editor.action.format
in the search box to view existing shortcuts.
To change the key combinations follow these steps:
- Click
editor.action.formatDocument
or editor.action.formatSelection
- A pen like icon appears to the left - click it.
- A pop-up appears. Press the desired key combination and press enter.