2

In VS Code, if I type:

function fname( $var ) {
}

It gets converted to:

function fname($var) {
}

Is there a setting that will work for ALL languages, like:

"format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParentheses": false 

Here are my relevant VS Code settings:

{
    "[js]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[php]": {
        "editor.defaultFormatter": "bmewburn.vscode-intelephense-client",
        "format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false
        "editor.insertSpaceBeforeFunctionParenthesis": true
    },
    "editor.detectIndentation": false,
    "editor.find.loop": false,
    "editor.formatOnSave": true,
    "editor.insertSpaces": false,
    "editor.minimap.enabled": false,
    "editor.renderWhitespace": "none",
    "editor.tabSize": 4,
    "editor.trimAutoWhitespace": true
}

Please note: I know if I remove "editor.formatOnSave": true, it'll stop, but I don't want to do that since I'll lose all my other formatting. I need a solution that works with "editor.formatOnSave": true.

GTS Joe
  • 3,612
  • 12
  • 52
  • 94
  • If you are using prettier, you should be aware that prettier is an *opinionated* formatter and you have limited configuration options (i.e. if you don't like it you may not be able to change it). – crashmstr Jul 22 '20 at 12:35
  • It's doing it for all my languages, not just JavaScript. – GTS Joe Jul 22 '20 at 12:42
  • Does this answer your question? [How do I stop VSCode auto formatting from deleting spaces inside parentheses?](https://stackoverflow.com/questions/53441149/how-do-i-stop-vscode-auto-formatting-from-deleting-spaces-inside-parentheses) – Brennan Jan 06 '23 at 02:01

0 Answers0