Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup automatic leading / trailng space in C# function declaration brackets in Visual Studio Code?

I have this:

public void Scale(float amount);

But I want this:

public void Scale( float amount );

Best would be if I could apply a rule to existing C# files as well.

like image 604
Geri Borbás Avatar asked Jun 27 '18 04:06

Geri Borbás


People also ask

How do you cut leading and trailing spaces from a string?

To remove leading and trailing spaces in Java, use the trim() method. This method returns a copy of this string with leading and trailing white space removed, or this string if it has no leading or trailing white space.

How do you fix trailing white spaces?

Hover the mouse on warning in VS Code or any IDE and use quick fix to remove white spaces. Press f1 then type trim trailing whitespace .

How do you remove unnecessary spaces in VS code?

press F1 and select/type "Trailing Spaces: Delete"


1 Answers

You can enable whitespace from below settings:

VS
1.Open VS Text Editor(Tools=>Options=>Editor)
2.Choose your language.For example(C#->Formatting->spacing)
3.Then tick up Insert space within argument list parentheses

VS Code:
1.Open VS User Settings (File > Preferences > User Settings).
2.Add a new "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": true, setting to the User Settings document on the right if it's not already there.
3.Save the User Settings file.
4.In the toolbar in the bottom right corner you will see an item that looks like the following: enter image description here
5.After clicking on it you will get the language list and select TypeScript.
6.Press Shift+ Alt+ F

like image 93
Oliver Avatar answered Oct 25 '22 18:10

Oliver