
How to install and configure the VSCode plugin Let's install and configure the VSCode plugin now. That's it - you have added prettier to your project. You can clone it by executing the following command: git clone git Visual Studio Code with your project opened click on menu -> Terminal -> New Terminal:

Let me show you how to set everything up.Īs an example project I'm going to use a piece of code I've created and uploaded as a GitHub repository. Isn't it cool? Think about how convenient it is to never have to think about code formatting again! What's important is that it is you who decide how the output format should look like so if you're not a fan of double quotes and semicolons just add the config file and from now on all the code you write will have the desired format:

Or when you copy-paste the code for example from stack overflow: What makes it even better is the Visual Studio Code plugin that allows for the live code auto-formatting as you type your code:

Prettier has wide support of programming languages and file formats such as: In other words, it's a tool that as input takes any format of your code (as long as it is syntactically correct) and then outputs nicely and orderly formatted code: It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary. Prettier is an opinionated code formatter. In this article, I am going to explain step by step how to configure your JavaScript project in Visual Studio Code to format the code automatically whenever you save the changes or paste the code to the editor.
