Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Prettier keyboard shortcut command in VS Code to format only a block of React code, not just format on file autosave?

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.

like image 494
richalk Avatar asked Jan 31 '20 09:01

richalk


People also ask

What is the shortcut for Prettier in VS Code?

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.

How do I get Prettier to format in save VS 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.

What is the shortcut to format code in Visual Studio?

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.


1 Answers

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

enter image description here enter image description here

like image 151
prashant kumar Avatar answered Sep 28 '22 16:09

prashant kumar