I press Shift+Enter, but not working, Ctrl+Enter start a new line, but not add semicolon at the end of previous line. Is there a
I just started using Visual Studio Code and felt this requirement myself yesterday. After a quick google search I found this nice extension called "Prettier". Being a little new to VSCode it took me a few hours to get it all setup but it works like a charm now. Here are the steps and my setup. I hope it helps others.
My coding environment: VSCode running on a Windows 10 desktop environment connecting to my codebase SMB share hosted on my development machine which is running Ubuntu server 18.04.
Solution Steps
node
on the Windows desktopnpm install -g prettier
Prettier
extension in VSCodeEdit the settings.json
file for VSCode and add the following
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
// Set the default
"editor.formatOnSave": true
Add the .prettierrc
file at the root of my codebase on the ubuntu host (e.g.: /var/www/html/tutorials
) with the following basic styling configuration
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80
}
(Ctrl+K Ctrl+F)
or to a selection (Shift+Alt+F)
Ctrl+S
adds the formatting while saving the file with no additional work required