Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Prettier - Code formatter" is not working in Visual Studio code

I have Visual Code Studio(1.41.1) Editor and I need Auto Formatter

I have installed this code format: Prettier - Code formatter Successfully installed but not working,

I also tried to use the command ext install esbenp.prettier-vscode that too was successful installation but is not working.

I checked that the composer is installed properly and the environment variable path is given correctly in my system, Also, I added it to the settings.json file by looking in the document: "phpformatter.composer": true but not success in auto-formatting my code

Visual Studio Code and System Restart also tried but did not succeed

Why can't I Auto Formatter in my Visual Studio code use this "Prettier - Code Formatter"? No errors are received, but the auto formatter is not working

like image 740
Udhav Sarvaiya Avatar asked Sep 05 '25 17:09

Udhav Sarvaiya


2 Answers

try this, it worked for me

File -> Preferences -> Settings (for Windows)

Code -> Preferences -> Settings (for Mac)

Search for "Default Formatter". In the dropdown, prettier will show as esbenp.prettier-vscode.

like image 69
Manan Gadhiya Avatar answered Sep 09 '25 00:09

Manan Gadhiya


Maybe the prettier extension is not working for Javascript file. Open your settings.json for VS Code and paste:

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }
}

This might work for you

like image 26
Anant Rawat Avatar answered Sep 09 '25 00:09

Anant Rawat