Sub topic 11
Configure Copilot per language
This chapter assumes you have installed the Copilot extension and signed in, and that you know how to open VS Code settings (the Settings UI and settings.json). It covers how to control where Copilot inline suggestions are active, how settings scopes interact, and the common mistakes that make a configuration appear to do nothing.
Why configure per language
Inline suggestions are useful in source code, but less useful in some file types. In plain text notes and Markdown prose, suggestions can distract you or insert wording you did not intend. In files that hold sensitive material, you may want Copilot off entirely. A per-language setting lets you keep Copilot on for most files and off for the few where it gets in the way.
The relevant setting is github.copilot.enable. It is an object. Each key is a language identifier, and each value is true or false.
The `github.copilot.enable` setting
Open the Command Palette and run Preferences: Open User Settings (JSON). Add this block:
{
"github.copilot.enable": {
"*": true,
"plaintext": false,
"markdown": false
}
}This does three things:
"*": trueis the default rule. It turns inline suggestions on for every language that has no more specific entry."plaintext": falseturns suggestions off for files whose language mode is Plain Text."markdown": falseturns suggestions off for Markdown files.
A specific language key always wins over the "*" wildcard. If a language has no key of its own, the wildcard applies.
Finding the language identifier
The key must be the VS Code language identifier, not the file extension and not the display name. These often differ.
| File type | Language identifier | Common wrong guess |
|---|---|---|
| Python | `python` | `py` |
| JavaScript | `javascript` | `js` |
| TypeScript | `typescript` | `ts` |
| TypeScript React | `typescriptreact` | `tsx` |
| Markdown | `markdown` | `md` |
| Plain Text | `plaintext` | `text`, `txt` |
| Shell script | `shellscript` | `bash`, `sh` |
To check the identifier of the file you have open:
- Look at the language mode in the status bar at the bottom right, for example "Python".
- Click it to open the language picker, which lists all modes.
- Alternatively, run Developer: Inspect Editor Tokens and Scopes from the Command Palette, or use Configure Language Specific Settings from the language picker. The latter shows the identifier in brackets, such as
[python].
If a key does not match a real identifier, VS Code does not report an error. The entry is silently ignored, which is a common source of confusion.
Turning Copilot on and off quickly
You do not always need to edit JSON. The Copilot icon in the status bar opens a menu with options for the current file's language and for all files. Choosing to disable completions for the current language writes the same github.copilot.enable entry for you. This is a convenient way to generate a correct key and then inspect it in settings.json.
Use the JSON approach when you want to review your rules in one place, copy them to another machine, or share them with a team.
How the pieces fit together
Per-language enablement is one layer. Copilot only produces a suggestion when several conditions hold at once.
If you disable a language and later wonder why suggestions are missing, this order is a good checklist. The same chain applies in reverse. Enabling a language in settings does not override a content exclusion rule set by your organization or repository.
Settings scopes
VS Code stores settings in more than one place, and a more specific scope overrides a broader one.
| Scope | Where it lives | Applies to |
|---|---|---|
| User | Your user `settings.json` | All projects on this machine (or synced machines) |
| Workspace | `.vscode/settings.json` in the project | Everyone who opens this project |
| Profile | The active VS Code profile | Only while that profile is selected |
Workspace settings override user settings. This is useful for teams. If a repository mostly contains documentation, you can commit a workspace setting that disables Markdown suggestions for everyone who opens it.
The override works on the setting as a whole. If your user settings contain the object above and the workspace defines its own github.copilot.enable, the workspace object replaces the user one for that project. This is a typical pitfall. Suppose the workspace file contains only this:
{
"github.copilot.enable": {
"markdown": false
}
}Depending on how VS Code merges object settings in your version, you should not assume your user-level "*": true still applies. To be safe, include the "*" key in any workspace override so the file states the full rule set.
Syncing
If you use Settings Sync, your user github.copilot.enable rules follow you to other machines. Workspace settings do not sync, because they travel with the repository instead.
Language-specific setting blocks versus `github.copilot.enable`
VS Code also lets you write settings inside a language block, such as "[python]": { ... }. That syntax is meant for settings that are defined as language-overridable, such as editor.tabSize or editor.formatOnSave. It is not the way to turn Copilot on or off.
This is correct for formatting:
{
"[python]": {
"editor.tabSize": 4
}
}This is not how Copilot is controlled. Do not put github.copilot.enable inside a [python] block. Use the object form with language keys, as shown earlier.
Related inline suggestion settings
Language rules are the main per-language control. Two other settings are worth knowing, because they change how suggestions behave even where Copilot is enabled.
editor.inlineSuggest.enabledis a general VS Code setting for inline suggestions from any provider. If it isfalse, Copilot's ghost text will not show, even whengithub.copilot.enableistruefor the language.github.copilot.editor.enableAutoCompletions(named differently in some versions) controls whether suggestions appear automatically as you type, or only when you trigger them yourself. If you prefer to request suggestions on demand, turn automatic completions off and trigger one manually.
Setting names can change between extension releases. Search for "copilot" in the Settings UI to see the names your installed version uses, and prefer the UI search over copying names from older articles.
A worked example
You work on a Python project that also has a docs/ folder of Markdown files. You want suggestions in code but not in prose.
- Open the Command Palette and run Preferences: Open Workspace Settings (JSON).
- Add the rules:
{
"github.copilot.enable": {
"*": true,
"plaintext": false,
"markdown": false
}
}- Save the file.
- Open a
.pyfile and type a descriptive comment and a function signature:
# Return the n-th Fibonacci number using iteration
def fibonacci(n):- Press Enter after the signature. A grey suggestion should appear. Press Tab to accept it.
- Open a
.mdfile and type a sentence. No grey suggestion should appear.
If step 5 fails, check the language mode in the status bar and confirm that you are signed in. If step 6 shows suggestions, check that the file's language mode is really Markdown and not Plain Text or another mode.
Files with an unexpected language mode
Language rules apply to the language mode, not the file name. A file named notes.txt is Plain Text. A file with no extension may default to Plain Text. A .env file may open as a Properties or dotenv mode, depending on installed extensions. If a rule does not seem to apply, change the mode with the status bar picker or add a file association:
{
"files.associations": {
"*.prompt": "markdown",
"*.notes": "plaintext"
}
}With these associations, *.prompt files are treated as Markdown and therefore follow your markdown rule.
Edge cases and gotchas
- Wildcard set to false. If you set
"*": false, Copilot is off everywhere unless you list a language astrue. This is a valid allowlist approach: turn everything off, then enable onlypythonandtypescript. - Disabled does not mean uninstalled. These rules affect inline suggestions. They do not sign you out, and they do not remove the Chat view. Chat can still read a file whose inline suggestions are disabled, unless that file is covered by content exclusion.
- Typos fail silently.
"Markdown"with a capital M or"md"will not match the identifiermarkdown. Copy identifiers from the language picker. - Extension-provided languages. Languages added by other extensions, such as Terraform or Svelte, have identifiers set by those extensions. Install the extension first, then check the identifier.
- Reload. Most changes to
github.copilot.enabletake effect immediately. If a rule does not seem to apply, run Developer: Reload Window before debugging further.
Verifying your configuration
When suggestions behave unexpectedly, work through this order:
- Confirm the language mode in the status bar.
- Open the Copilot status bar menu and check whether completions are enabled for that language.
- Search
settings.json(both user and workspace) forgithub.copilot.enableand look for a workspace override. - Check
editor.inlineSuggest.enabled. - Check the Copilot output log, available from the Output panel, for errors that point to sign-in or network problems.
The last step connects to the troubleshooting chapter, which covers sign-in failures and network issues in detail.
Exercise
Your workspace settings.json contains "github.copilot.enable": { "markdown": false }. Copilot suggestions have stopped appearing in your Python files too, although your user settings set "*": true. What is the most likely cause, and how do you fix it?
Show answer
The workspace setting overrides the user setting, so the user "*": true rule may no longer apply. Add "*": true to the workspace object so the rule set is complete: { "*": true, "markdown": false }. Then confirm the language mode of the Python file in the status bar.
Exercise
You want Copilot active only for Python and TypeScript. Write the github.copilot.enable object, and name the identifier you would use for TypeScript React files if you wanted them included.
Show answer
Use { "*": false, "python": true, "typescript": true }. For TypeScript React files, add "typescriptreact": true. The "*": false entry turns off every other language, and each specific key overrides it.
Exercise
You add "md": false to github.copilot.enable, but suggestions still appear in README.md. Why, and what should you change?
Show answer
md is a file extension, not a language identifier, so VS Code ignores the key without any error. Replace it with "markdown": false, and confirm the identifier in the status bar language picker.