Coding Standards are collections of best practices for writing codes, most likely you will find them in the documentation of your favorite programming language.
In this article I will show you how to configure Visual Studio Code to format your code and always make it beautiful according to the WordPress Coding Standards.
Make sure you have the following installed on your computer:
- Visual Studio Code (obvioulsy)
After ensuring that all the prerequisites have been met, let’s go to what matters:
If you received permission error when installing a dependency, set the composer permissions
Now that we have been able to use
phpcs, we need to
configure what Coding Standard we want:
If we stop here, we’ll be able to format our code through the command line:
But what we want, is with a simple keyboard shortcut, make it happen directly from our code editor.
To achieve this, we need to install the
phpcbf extension in the
Visual Studio Code (available at this link),
and configure the following:
Now, using a Visual Studio Code shortcut (or context menu), we have already been able to meet the WordPress code pattern requirements.