HomeVS Code / Dev EnvVSCodeの言語別設定は、複数設定すると優先度が落ちる仕様
VSCodeの言語別設定は、複数設定すると優先度が落ちる仕様

VSCodeの言語別設定は、複数設定すると優先度が落ちる仕様A quirk in VSCode's language-specific settings causes priority to drop…

AI2 点サマリ2 key points
  • 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 解説本文です。元記事全文の転載・翻訳ではありません。This AI explainer is generated from the summaries and collected metadata, not from a reproduction or translation of the full source article.

VSCodeの言語別設定(language-specific settings)で、複数の言語をまとめて指定すると設定の優先度が下がる挙動が改めて注目を集めている。QiitaなどのブログでVSCodeの設定に関する報告として取り上げられた内容で、後から書いた設定が期待通りに上書きされないケースがあるため、実務での設定管理に影響しうる知見だ。

VSCodeでは、settings.jsonの中で「[javascript]」のように角括弧で言語識別子を囲むことで、その言語にだけ適用されるエディタ設定を書ける。タブ幅やフォーマッタ、改行コードなどを言語ごとに変えたい場合に多用される仕組みだ。ここで「[javascript][typescript]」のように複数の言語を一つの括弧列にまとめて指定することも可能だが、この書き方は単一言語を指定した場合よりも優先度が低くなるとされる。

つまり、単一言語を対象にした設定は、複数言語をまとめた設定よりも強く適用される。JSONの一般的な感覚では「後に書いたものが勝つ」と考えがちだが、言語別設定においては記述順ではなく、指定の粒度が優先順位を左右する可能性がある。そのため、複数言語向けの共通設定と特定言語向けの個別設定が競合すると、意図とは異なる値が使われることがある。

VSCodeで言語別設定を複数記述した場合、後に書いた設定の優先度が期待通りに適用されない挙動があることが報告された。
🔷 VS Code / Dev Env · 本記事のポイント

この挙動自体はVSCodeの設定解決の仕様に沿ったものと見られ、バグというよりは仕様上の落とし穴に近い。VSCodeの設定はデフォルト、ユーザー、ワークスペース、フォルダ、そして言語別という多層構造で解決されるため、レイヤーが増えるほど競合の把握が難しくなる。EditorConfigやPrettier、ESLintといった外部ツールと併用している環境では、どこで最終的な値が確定しているのかがさらに見えにくくなる点にも注意が要る。

対策としては、複数言語をまとめた指定と単一言語の指定を安易に混在させない、あるいは言語ごとに設定を明示的に分けて書くことが挙げられる。設定が反映されない場合は、コマンドパレットから設定エディタを開き、対象言語で実際に適用されている値を確認するとよいだろう。言語別設定は便利な半面、優先順位のルールを理解して使うことが求められる。

Visual Studio Code allows developers to customize the editor on a per-language basis, so that, for instance, JavaScript files use two-space indentation while Go files use tabs. A recently shared Qiita post draws attention to a subtle quirk in how these language-specific settings are prioritized: when multiple entries are defined, resolution does not always follow the order a developer expects, and settings written later may not override those written earlier. For teams that depend on per-language overrides to enforce consistent formatting and editor behavior, this is a practical detail worth knowing.

Language-specific configuration in VSCode is written in settings.json using a bracketed language identifier as the key. A block such as "[javascript]" holds settings that apply only to files VSCode recognizes as JavaScript. These scoped entries take precedence over general, non-language settings, which is exactly what lets a globally defined editor.tabSize be selectively overridden for a given file type. The same layering applies across the configuration hierarchy, where default, user, workspace, and workspace-folder scopes stack in a defined order, with more specific scopes winning over broader ones.

The behavior described in the post concerns what happens once several language-specific blocks come into play. According to the report, adding multiple entries can cause the priority of a later definition to drop rather than rise, so that an override a developer intends to apply does not take effect. In other words, the mental model of "the last rule wins" does not reliably hold for these blocks. Because JSON objects do not guarantee that overlapping keys behave like a simple ordered list, the outcome can be counterintuitive, especially when the same setting appears in more than one place.

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.
🔷 VS Code / Dev Env · Key takeaway

One common source of confusion is the combined-selector syntax, where a single key such as "[javascript][typescript]" applies the same block to multiple languages at once. This is convenient, but it changes how a setting is scoped compared with writing separate "[javascript]" and "[typescript]" blocks. When a combined selector and an individual selector both touch the same property, the resulting precedence may not match intuition, and it is easy to end up with a value other than the one most recently written. The safest approach appears to be avoiding the same property in overlapping selectors, and keeping each language's overrides in a single, clearly scoped block.

To diagnose these conflicts, VSCode offers tooling that makes the effective value visible. The Settings editor can be filtered by language using the "@lang:" filter, and inspecting a setting shows which

  • 出典SourceQiita VSCodeコミュニティCommunity
  • 直近30件の平均重要度Avg importance, last 301=Info · 2=Medium · 3=High
  • 配信形式FormatブログBlog
  • 重要度Importance重要度 MediumMedium priority(VS Code / Dev Env 50件中、同等以上 30件)(30 of 50 VS Code / Dev Env entries are equal or higher)
  • 情報の寿命Half-life📘 中期 (チュートリアル)Medium-term (tutorial)
  • 原文言語Source languageJA
  • 収集日時Collected2026/07/22 13:57

本ページの本文と要約は 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).

🔷VS Code / Dev Env の他の記事More from VS Code / Dev Envもっと見る →View more →