Using Prettier: Anyone know the keyboard shortcuts to auto-format a single block of javascript in VSCode on highlight, without having to save the entire file using Prettier to use auto formatting.
We will start by installing the Prettier extension for VS Code. Once you have installed it, you can use it with CTRL + CMD + P (MacOS) or CTRL + Shift + P (Windows) to manually format a file or a selection of code.
Automatically Format Document on VS Code Using PrettierOpen the VS Code Settings menu by tapping “Command + ,(comma)” if you use a Mac. Click on “Control + ,(comma)”, if you are a Windows user. Go to the search bar and input “Editor: Format on Save.” Ensure it has a checkmark.
In an existing project, open the document that you want to format, right-click inside the document, and select Format Document. In the default configuration for Visual Studio Code, the command can be run using the shortcut Alt+Shift+F.
you can create you own default keyboard shortcut in VS code for formatting documents like in my case prettier code format command is shift+window+F but it is creating issue in mac so i changed the short cut command for it, for more information can refer below screenshots
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With