Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Prettier for formatting .ejs files in VS Code

I want to use prettier for formatting my ejs files by adding custom rules.

Right now I am using files associations of html for ejs files.

I have added the following code in the settings.json file: "files.associations": { "*.ejs": "html" },

like image 834
Saad Bilal Avatar asked May 15 '19 04:05

Saad Bilal


People also ask

How do you use prettier formatter in VS Code?

For those on Windows, click “Control + Shift + P.” Search “Format” in the search bar, then pick “Format Document.” Select your preferred format from the available options and click on “Configure.” Click on “Prettier – Code Formatter” to format the code.

How do I use prettier auto format?

Command+Shift+P to open it. It will show search bar with right arrow >, just start typing Format Document With, and you will come up with results as below. Select Format Document With and again you will be asked for few options. Select Prettier — Code Formatter and your file will be formatted.


1 Answers

Unfortunately Prettier does not currently support EJS. The list of supported languages are listed in their docs https://prettier.io/docs/en/index.html

However, they do support plugins so someone could add support https://prettier.io/docs/en/plugins.html

like image 163
Lee Trout Avatar answered Nov 10 '22 10:11

Lee Trout