-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disabling Format on Save for YAML Files Does Not Work #201752
Comments
So, which extension does format YAML files in your case? |
@jrieken I remember being able to disable a lot of built-in language-specific features in the Extensions section a couple years ago, but now I only see Extensions I installed from the Marketplace. |
We don't ship with that setting. Please check yours and make sure you have no language specific enablement for format on save |
@jrieke Below is my entire VS Code config: {
// ------------------
// General
// ------------------
"breadcrumbs.enabled": true,
"editor.bracketPairColorization.enabled": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.codeLens": false,
"editor.comments.ignoreEmptyLines": false,
"editor.fontFamily": "Consolas",
"editor.fontSize": 19,
"editor.formatOnSave": true,
"editor.guides.bracketPairs": "active",
"editor.minimap.enabled": false,
"editor.mouseWheelZoom": true,
"editor.semanticHighlighting.enabled": true,
"editor.suggestSelection": "first",
"editor.tokenColorCustomizations": {
"comments": "#FF2D00" // Make all comments Red.
},
"explorer.compactFolders": false,
"extensions.ignoreRecommendations": true,
"files.associations": {
"*.service": "shellscript" // For highlighting purposes, treat certain files as another language.
},
"files.trimTrailingWhitespace": true,
"git.openRepositoryInParentFolders": "never",
"security.workspace.trust.enabled": false,
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"terminal.integrated.enableMultiLinePasteWarning": false,
"terminal.integrated.enablePersistentSessions": false,
"terminal.integrated.profiles.windows": {
"Command Prompt": {
"args": [],
"icon": "terminal-cmd",
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
]
},
"Git Bash": {
"source": "Git Bash"
},
"PowerShell": {
"icon": "terminal-powershell",
"source": "PowerShell"
}
},
"window.titleBarStyle": "custom",
"workbench.editor.openPositioning": "last",
"workbench.iconTheme": "material-icon-theme",
"workbench.settings.editor": "json",
"workbench.sideBar.location": "right",
"workbench.startupEditor": "none",
// --------------
// Go
// --------------
"go.formatFlags": [
"-s",
"-w"
],
"go.formatTool": "gofmt",
"go.lintFlags": [
"--fast"
],
"go.lintOnSave": "workspace",
"go.lintTool": "golangci-lint",
"go.toolsManagement.autoUpdate": true,
// ------------------
// TODO Tree
// ------------------
"todo-tree.filtering.excludeGlobs": [
"**/c:\\go/**",
"**/vendor/**"
],
"todo-tree.general.tags": [
"BUG",
"HACK",
"FIXME",
"TODO",
"XXX",
"[ ]",
"[x]"
],
"todo-tree.highlights.customHighlight": {
"TODO": {},
"FIXME": {}
},
"todo-tree.highlights.defaultHighlight": {
"foreground": "#008000",
"type": "none"
},
"todo-tree.highlights.enabled": false,
"todo-tree.regex.regex": "(//|#|<!--|;|/\\*|^|^\\s*(-|\\d+.))\\s*($TAGS)",
"todo-tree.tree.tagsOnly": true,
"window.zoomLevel": 1,
"[yaml]": {
"editor.formatOnSave": false
},
"workbench.colorTheme": "Sublime Monokai"
} |
The problem can be easily reproduced when you have a YAML file that has:
When you save the file, the spaces get removed. I raised this issue because the autoformatting changes make it difficult for code reviewers to view the actual changes. I have format on save enabled for all languages and then try to disable it just for YAML files, which currently doesn't work: "editor.formatOnSave": true,
"[yaml]": {
"editor.formatOnSave": false
}, |
VS Code doesn't ship with a YAML formatter out-of-the box.
|
@aeschli |
Type: Bug
I don't have any YAML-related extensions installed.
I also disabled all installed extensions and reloaded VS Code during testing, so the issue is not caused by an extension.
This configuration does not work:
Is there a way to disable format on save just for YAML files?
VS Code version: Code 1.85.1 (0ee08df, 2023-12-13T09:49:37.021Z)
OS version: Windows_NT x64 10.0.22000
Modes:
System Info
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Extensions (10)
A/B Experiments
The text was updated successfully, but these errors were encountered: