To enable Prettier on save in Visual Studio Code
Install Prettier Extension:
- Open VS Code and go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window.
- Search for "Prettier - Code formatter" and install it.
Set Prettier as Default Formatter:
- Open the Command Palette by pressing Ctrl + Shift + P (or Cmd + Shift + P on Mac).
- Type and select Preferences: Open Settings (JSON).
- Add the following lines to your settings.json file:
1 2 3 | "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true |
Multi-Line Comment/Uncomment Shortcut:
- Mac: Cmd + /
- Windows: Ctrl + /
- Linux: Ctrl + /
Block Selection (Column Mode) Shortcuts:
Select a rectangular block:
- Mac: Shift + Option + Drag (mouse)
- Windows: Shift + Alt + Drag (mouse)
- Linux: Shift + Alt + Drag (mouse)
Extend selection by columns:
- Mac: Cmd + Shift + Option + Arrow Keys
- Windows: Ctrl + Shift + Alt + Arrow Keys
- Linux: Ctrl + Shift + Alt + Arrow Keys