Supersharp
Supersharp

Reputation: 31171

How to add a white space between function name and open bracket in VS Code

In the JavaScript editor of Visual Studio Code, I would like to add a white space between the function name and the open bracket (when function is defined).

function name ()   // <- whitespace before brackets
{
   ...
}

But when I press [Enter] the white space is automatically removed.

Is it possible to keep it (or to auto-instert one white space), without disabling the auto-formatter?

I know I can use [Ctrk + Z] to remove the last auto-formatting but I'd like to avoid that.

Upvotes: 1

Views: 2233

Answers (2)

Nalaka Rajamanthri
Nalaka Rajamanthri

Reputation: 162

Add this to your settings.json and format the file using Shift + Alt + F

"javascript.format.insertSpaceBeforeFunctionParenthesis": true

Or set it in settings menu

enter image description here

Works in VSCode 1.64

Upvotes: 2

TerrySu
TerrySu

Reputation: 168

function name () {
    ...
}

Is this code you need? Just use the shortcut: Shift + Alt + F

Upvotes: 2

Related Questions