DEV Community

Cover image for Improve your productivity when working with React by making these changes in Visual Studio Code

Improve your productivity when working with React by making these changes in Visual Studio Code

Yogesh Chavan on July 05, 2020

In this article, we will see some of the settings you can do in Visual studio code to improve your productivity when working with React So Let's g...
Collapse
 
naingaungphyo profile image
Naing Aung Phyo

Thanks for awesome guide!
I have a question about ES7 React snippets extension.
For example, if we use imr, there will be import statement but there is no semicolon at the end. Do you have any idea about how to include it?

Collapse
 
myogeshchavan97 profile image
Yogesh Chavan • Edited

Thank you. For adding semicolon, you need to add semi: true property to .prettierrc file. Alternatively you can search for prettier semicolon in visual studio code user setting through command palette and enable semicolon

Collapse
 
naingaungphyo profile image
Naing Aung Phyo • Edited

So does it mean that, I can't add semicolon without using prettierrc; no setting in snippets extension.

Thread Thread
 
myogeshchavan97 profile image
Yogesh Chavan

I mean In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open command palette and type setting and then select "Preferences: Open User Settings" option and then search for prettier semicolon

Thread Thread
 
myogeshchavan97 profile image
Yogesh Chavan

If you enable there, then there is no need of .prettierrc for adding semicolon

Thread Thread
 
naingaungphyo profile image
Naing Aung Phyo

Thanks, it is working now.
So it means I need to use in combination of prettier(prettier semicolon setting true) + user setting ("editor.formatOnSave": true) to add semicolon.

Thread Thread
 
myogeshchavan97 profile image
Yogesh Chavan

No.only one of them is enough

Thread Thread
 
naingaungphyo profile image
Naing Aung Phyo • Edited

It doesn't work without adding user setting ("editor.formatOnSave": true) for me. Only making a check at prettier(prettier semicolon setting true) doesn't add semicolon at the end after using snippets. Do you have any idea?

Thread Thread
 
myogeshchavan97 profile image
Yogesh Chavan

Sorry for misunderstanding your question. The first thing we did after installing the prettier extension is to check the checkbox for format on save so that's the main thing we need to do only once for your editor.

All other options will only work if that checkbox is checked and to automatically add semicolon on save, either you need to add the option semi: true in .prettierrc or check the checkbox to add semicolon in prettier settings

Thread Thread
 
naingaungphyo profile image
Naing Aung Phyo

Yeah it is working after saving a file. But what I wanted is to add semicolon just immediately after using snippets.

Thread Thread
 
myogeshchavan97 profile image
Yogesh Chavan

You add all the snippets you want on separate line as I have shown in the gif in the article and finally when you save the file, semicolons will be added automatically.

I have also updated the article just now, for the steps to enable the semicolons under "Automatically add a semicolon at the end of the line" section

Thread Thread
 
naingaungphyo profile image
Naing Aung Phyo

I mean, I want to add semicolon before saving the file.

Thread Thread
 
myogeshchavan97 profile image
Yogesh Chavan

The snippets extension does not add the semicolon automatically so you need to save the file to add the semicolons

Thread Thread
 
naingaungphyo profile image
Naing Aung Phyo

Yeah, looks like that is the only possible way. Thanks for your sincere replies.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
myogeshchavan97 profile image
Yogesh Chavan

Hi James, Can you please make sure you've installed the correct extension?

You can also try restarting the Visual Studio Code IDE.

Try rafce instead of rce to check If that works and wait till it shows the autocomplete snippet before hitting the enter key after typing rafce

Collapse
 
arung86 profile image
Arun Kumar G

I had forgotten Lorem short cut in Emmet, good tips !
just enabled emmet with my react project

Collapse
 
myogeshchavan97 profile image
Yogesh Chavan

Awesome 👍