Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode: turn off format on save only in specific directory

I'd like to configure VSCode to not auto-format files in a specific directory.

Background: I'm writing a library that renders json into html. For testing, I'm comparing the results with pre-rendered html snippets. Unfortunately, VSCode *cks up my formatting of the html files with it's auto-format feature. Although auto-formatting is very handy for my actual code, I'd like to turn it off for those snippets.

Is there any option to turn it off for files in a specific directory or for files matching a specific pattern in filename? If yes: Is it possible to have the settings stored in the project folder?

So far I only found the option to turn auto-formatting on/off per language. This is close but not perfect, since there are other html files in my project that would benefit from auto-formatting.

like image 595
Fred Avatar asked Feb 14 '19 00:02

Fred


People also ask

How do I turn off auto format in save VS Code?

Enable/Disable Format On Save Open up VSCode Command Palette by pressing Ctrl + Shift + P. Search and select Open Settings (UI). Just start typing and it will auto-fill. Once there's a match, you can hit enter immediately, or manually click on the right option.

How do I turn off formatting in Visual Studio?

The solution was to go to 'Tools > Options > Text Editor > Basic > VB Specific' and turn 'Pretty Listing' OFF.

How do you ignore files in VS Code?

You can use the exclude folder option to remove unwanted folders like node_modules or others you don't want to open in Visual Studio Code. To exclude a folder, go to File > Preferences, and search for file. exclude in the search settings. You can add the pattern of the folder you don't want Visual Studio Code to open.


Video Answer


1 Answers

Try to add (for example, if you language is JavaScript):

"[javascript]": {
    "editor.formatOnSave": true
},
"files.associations": {
    "src/some-folder/*.js": "plaintext"
}
like image 127
Or Assayag Avatar answered Oct 21 '22 20:10

Or Assayag