VS Code

To enable Prettier on save in Visual Studio Code

Install Prettier Extension:

  1. 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.
  2. Search for "Prettier - Code formatter" and install it.

Set Prettier as Default Formatter:

  1. Open the Command Palette by pressing Ctrl + Shift + P (or Cmd + Shift + P on Mac).
  2. Type and select Preferences: Open Settings (JSON).
  3. 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

Leave a Comment