Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio's JavaScript code formatting in for loops

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?

);

like image 595
Kendall Frey Avatar asked May 23 '13 14:05

Kendall Frey


People also ask

How do I automatically format code in Visual Studio Code?

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.

How do I automatically indent code in Visual Studio?

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.

How do I display JavaScript output code in Visual Studio?

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.

What is the code for beautify code in Visual Studio?

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.


1 Answers

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.

like image 182
James Avatar answered Oct 03 '22 10:10

James