There is a question about suppressing editor.formatOnSave for specific file extensions (languages) but I have a different question instead: how can I suppress this feature for one specific file in my workspace?
I want to suppress it in the repository somehow, with a config or hint in a comment, or some such, so I can prevent anyone from accidentally doing it wrong. I cannot tell my 20ish teammates to always "save without formatting", nor could I myself remember that at all times.
I have a ./vscode/settings.json file that has:
"editor.formatOnSave": true,
and it works wonderfully for all files in my workspace. However, I want to suppress it for my app-routing.module.ts file (it's an Angular project) because the auto-formatting there hurts readability more than it helps.
How to disable editor.formatOnSave for one specific file?
When I or a colleague use "Save" (CTRL + S on Windows) or "Save All" (CTRL + K, S on Windows) the auto formatting should not be triggered for that file.
What I've tried:
- Check all answers in the related question (so e.g.
"[javascript]": { "editor.formatOnSave": false } - Have a
.vscode/settings.jsonfolder in subfolders, but that's not supported - Include
/* eslint-disable prettier/prettier */in my file (AFAIK prettier is my formatter for TypeScript files), and read through this open prettier issue on GitHub - Create a
.prettierignorefile and add my file
None of these worked.