The default code formatting for JavaScript in Visual Studio 2012 does this with for
loops:
for (var a = b; a < c; a++)
{
}
for (var a = b() ; a < c; a++)
{
}
for (var a = b; a < c() ; a++)
{
}
for (var a = (b) ; a < (c) ; a++)
{
}
Notice the spaces after b()
, c()
, (b)
, and (c)
.
Where is the option to remove those spaces, or does VS just have a phobia of frowning winky faces?
);
To automatically format the file on save, In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type setting and then select Preferences: Open User Settings option. Search for format on save setting and check the checkbox.
Auto formatting settings in Visual Studio Show activity on this post. Select the text you want to automatically indent. Click menu Edit → Advanced → *Format Selection, or press Ctrl + K , Ctrl + F . Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.
After installation of the code runner extension, open JavaScript Code in VSCode. Press CTRL+ALT+N shortcut or you may press F1 then write Run Code to run the code. Subsequently, you will see the following output in the “OUTPUT” tab.
The code formatting is available in Visual Studio Code through the following shortcuts: On Windows Shift + Alt + F. On Mac Shift + Option + F. On Linux Ctrl + Shift + I.
Use Resharper. It's a brilliant tool for C#, and it also has really good JavaScript support - including a JS Lint plugin which will allow you to enforce JS code conventions / styles.
It's not free, though - but it'll make your code more consistent and higher quality.
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