Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode - Disable ALL Auto Formatting on Save

I'm editing someone else's code and I only want to change 1 line of a 9000 line file. But every time I save, VS Code formats the entire file and removes any trailing white space. This is a no-no because when I push this up, the reviewer will have no idea which line to look at.

I've tried disabling prettier, adding all files to .prettierignore, going into VS Code settings and disabling any suggestions of a formatter or white space trimming, turning off formatOnSave.

Here is my .vscode/settings.json

{
  "prettier.disableLanguages": [
    "js",
    "json",
    "javascript"
  ],
  "javascript.format.enable": false,
  "typescript.format.enable": false,
  "json.format.enable": false,
  "html.format.enable": false,
  "emmet.showAbbreviationSuggestions": false,
  "css.validate": false,
  "editor.defaultFormatter": null,
  "editor.formatOnSave": false,
  "[javascript]": {
      "editor.formatOnSave": false,
      "editor.defaultFormatter": null
  },
  "editor.trimAutoWhitespace": false,
  "diffEditor.ignoreTrimWhitespace": false,
  "files.trimTrailingWhitespace": false,
  "files.trimFinalNewlines": false,
"eslint.format.enable": false,
"files.autoSave": "off",
}

The only thing that seems to work is if I do CTRL + SHIFT + P, then SAVE WITHOUT FORMATTING. But what setting can I have so I can just do that with normal saving?

like image 523
inbtw33n Avatar asked May 15 '20 19:05

inbtw33n


People also ask

Why is VS Code formatting on save?

You have configured prettier to format as per the default settings. If you don't see the code formatted automatically on file save then it might be because you have multiple formatters installed in VS Code.

How do I enable auto format in VS Code?

The code formatting is available in Visual Studio Code (VSCode) through the following shortcuts or key combinations: On Windows Shift + Alt + F. On macOS Shift + Option + F. On Linux Ctrl + Shift + I.


1 Answers

Did you try adding

"editor.formatOnSave": false

in your user settings rather than in your project settings?

like image 135
Guillermo Brachetta Avatar answered Nov 16 '22 09:11

Guillermo Brachetta