
VSCodeの言語別設定は、複数設定すると優先度が落ちる仕様A quirk in VSCode's language-specific settings causes priority to drop…
匿名の公開いいねです。記事の保存・お気に入りではなく、Featured、Top 3、重要度、掲載順位には影響しません。仕組みとプライバシーAnonymous public likes are reactions, not saved articles or bookmarks. They do not affect Featured, Top 3, importance, or listing order.How it works and privacy
- VSCodeで言語別設定を複数記述した場合、後に書いた設定の優先度が期待通りに適用されない挙動があることが報告された。
- 設定の競合を避けるための注意点として実務上重要な知見である。
- A quirk in VSCode's language-specific settings causes priority to drop unexpectedly when multiple entries are configured, meaning later rules may not override earlier ones as intended.
- Developers relying on per-language overrides should be aware of this behavior.
本ページの本文と要約は AI による自動生成です。日本語版と英語版は言語ごとに独立して生成されるため、表現や詳しさが異なる場合があります。正確性は元記事 (qiita.com) をご確認ください。The body and summaries are AI-generated independently for each language, so wording and detail may differ. Verify accuracy at the original source (qiita.com).
要約と収集メタデータに基づく AI 解説。元記事全文の転載・翻訳ではありません。AI explainer based on the summaries and collected metadata, not a copy or translation of the full source article.
言語別設定
VSCodeでは、言語別設定の対象を複数まとめて指定すると、設定の優先度が期待とは異なる場合がある。特に、単独言語のユーザー設定が、リポジトリ側に置かれた複数言語のローカル設定を上書きする点に注意が必要だ。
settings.json
ディレクトリごとの設定は、.vscode/settings.jsonに記述できる。一方、ユーザー自身もsettings.jsonに設定を持つことができ、どちらでもプログラミング言語ごとの設定や、複数の言語を対象とした設定を記述できる。
この組み合わせで競合が起きた場合、複数言語を対象にしたローカル設定より、単独言語を対象にしたユーザー設定が優先される。これはVSCodeの仕様であり、今後変更する予定はないと明言されている。
タブサイズ
たとえば、ローカル側の複数言語設定で「editor.tabSize」を2にしていても、ユーザー側の単独言語設定で8にしていれば、2は無視されて8が反映される。以前、自分用のプロジェクトなどに合わせて作成した単独言語設定が残っていると、リポジトリ側の複数言語設定を無効にすることがあり得る。
フォーマッタ
同じ競合は「editor.defaultFormatter」でも起こる。ローカル設定で「esbenp.prettier-vscode」を指定していても、単独言語のユーザー設定に「dbaeumer.vscode-eslint」があれば、ローカル側は無視され、手動フォーマット時にはeslintが使われる。
タブサイズは結果を確認しやすいが、フォーマッタの競合では、リポジトリに置かれたフォーマット設定が効かないように見え、差分が大量に生じる可能性がある。設定を確認する際は、記述順だけでなく、単独言語と複数言語という指定方法の違いも切り分ける必要がある。
VSCode language-specific settings
VSCode allows programming-language-specific options to be placed in a directory’s .vscode/settings.json file, while users can also maintain their own settings.json. The way these two levels interact matters because a user setting may override a repository’s local configuration unexpectedly.
Language-specific configuration can target either one language or multiple languages. When these forms conflict, their priority does not necessarily follow the order a developer might expect.
Multiple entries are configured
The key behavior is that a single-language user setting overrides a local setting that targets multiple languages. This is a VSCode specification, and it has been explicitly stated that there are no plans to change it.
As a result, a single-language option previously added for a personal project can disable a multi-language option stored in a repository. The conflict is based on how the language targets are configured, rather than simply on which rule appears later.
Priority can drop unexpectedly
Tab size makes the behavior easy to see. In the example, a local "editor.tabSize" value of 2 is ignored, while the user’s value of 8 takes priority. This can make it appear that the repository setting is not being applied.
The same behavior can create a more difficult problem when the conflicting option controls formatting. A repository may contain formatting configuration, yet a user-level setting can cause a different formatter to be selected.
Per-language overrides
In the formatter example, the local settings.json specifies "esbenp.prettier-vscode" as "editor.defaultFormatter", but that value is ignored. The user setting specifies "dbaeumer.vscode-eslint", which takes priority and is used when the file is formatted manually.
That change can produce many differences despite the repository containing its own formatter choice. Developers relying on per-language overrides therefore need to account for the fact that a single-language user configuration can supersede a multi-language local configuration.
ポコとTECHガイドPoko & TECH Guide
ポコと当サイトのTECHガイドが、記事の要約と収集した情報から読みどころを語るAI生成の対話です。Poko and TECH Dashboard's own TECH Guide discuss the article's highlights in an AI-generated conversation based on its summary and collected source details.
- ポコPokoタブ幅2の設定が無視されて、8が優先されることもあるんだ。これって大きいこと?A tab size of 2 can be ignored while 8 takes priority? Is that a big deal?
- TECHガイドTECH Guide影響は大きくなりうるのう。この記事では、フォーマッタまで意図と違えば差分が大量に出る可能性があり、仕様の変更予定もないとされておる。It can be. The article warns that an unexpected formatter may create lots of diffs, and this behavior is stated to have no planned change.
- ポコPoko複数言語をまとめた設定は優先度が落ちるって、つまりどういうこと? 後に書けば勝つわけじゃないの?What does it mean that a setting for multiple languages gets lower priority? Doesn’t the later rule win?
- TECHガイドTECH Guideユーザー側の単独言語設定が、リポジトリ側の複数言語設定より優先されるということじゃ。後ろの設定が必ず勝つ仕組みではないのう。A single-language user setting can outrank a multi-language repository setting. So no, the rule written later does not necessarily win.
- ポコPoko僕ならリポジトリでprettierを指定して、みんなの整形をそろえたいな。これなら安心?I’d set prettier in the repository so formatting stays consistent. Would that be safe?
- TECHガイドTECH Guide記事の例では、ユーザー設定のeslintがローカルのprettierを上書きし、手動整形でeslintが使われるんじゃ。自分のsettings.jsonも確認したいのう。In the example, the user’s eslint setting overrides local prettier, so manual formatting uses eslint. It would be wise to check your own settings.json too.





