B. Timsa
B. Timsa

Reputation: 41

VS Code, how to exclude directory from editor.formatOnSave

i am using a php formatter in VSCode, my problem is that on some view files where there is also html the code get messy, so i am trying to exclude the folder from the formatOnSave

This is my current configuration.

"editor.formatOnSave": true,
"[php]": {
    "editor.formatOnSave": false
}

How can i have the php format on save on all folders except the view one?

Upvotes: 4

Views: 2092

Answers (2)

rustyx
rustyx

Reputation: 85266

If you're using Beautify, then can use the beautify.ignore option:

Example:

/* ignore all files named 'test.js' not in the root folder,
   all files directly in any 'spec' directory, and
   all files in any 'test' directory at any depth
*/
"beautify.ignore": ["*/test.js", "**/spec/*", "**/test/**/*"]

/* ignore all files ending in '_test.js' anywhere */
"beautify.ignore": "**/*_test.js"

Upvotes: 0

user838494
user838494

Reputation: 479

If you're using Prettier, then you can create a .prettierignore file and include the directory that you want to exclude from formatting. You may need to go to the extension settings for Prettier and set the file path for .prettierignore for it to take effect.

Upvotes: 3

Related Questions