Visual Studio Code
Coding Issues
Tab Key Problem
Software Troubleshooting
Coding Environment

Visual Studio Code Tab Key does not insert a tab

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

When the Tab key stops inserting tabs in VS Code, the most common cause is that "Tab Moves Focus" mode is turned on. Press Ctrl+M (or Ctrl+Shift+M on macOS) to toggle it off. If that does not fix it, there are several other settings and extensions that can hijack the Tab key. This article covers every cause and the exact fix for each one.

Fix 1: Toggle Off "Tab Moves Focus" (Most Common)

VS Code has an accessibility feature called "Tab Moves Focus" that changes the Tab key from inserting whitespace to cycling between UI elements (sidebar, editor, terminal, etc.). This is the single most common reason the Tab key stops working for indentation.

How to tell if it is active: Look at the status bar at the bottom of VS Code. If you see "Tab Moves Focus" displayed there, this is your problem.

How to fix it:

  • Keyboard shortcut: Press Ctrl+M (Windows/Linux) or Ctrl+Shift+M (macOS)
  • Command Palette: Ctrl+Shift+P and search for "Toggle Tab Key Moves Focus"

This setting often gets toggled accidentally because Ctrl+M is easy to hit unintentionally.

You can also disable it in settings to prevent accidental toggling:

json
{
    "editor.tabFocusMode": false
}

Fix 2: Disable Emmet Tab Expansion

Emmet is built into VS Code and uses Tab to expand abbreviations (e.g., typing div.container then Tab expands it to <div class="container"></div>). When Emmet intercepts Tab, regular indentation does not happen.

Symptoms: Tab does nothing in non-HTML/CSS files, or inserts unexpected HTML markup.

Fix:

json
{
    "emmet.triggerExpansionOnTab": false
}

After disabling this, Emmet still works. You just need to use Ctrl+Space or the suggestion menu to expand abbreviations instead of Tab.

Fix 3: Adjust Tab Completion Settings

VS Code can use Tab to accept autocomplete suggestions and cycle through snippet placeholders. This can conflict with regular indentation.

Settings to check:

json
1{
2    "editor.tabCompletion": "off",
3    "editor.acceptSuggestionOnTab": true,
4    "editor.suggest.insertMode": "replace"
5}
SettingOptionsEffect on Tab Key
editor.tabCompletion"on", "off", "onlySnippets""on" makes Tab accept any suggestion
editor.acceptSuggestionOnTabtrue, falseWhether Tab accepts the highlighted suggestion
editor.snippetSuggestions"top", "bottom", "inline", "none"Where snippets appear in suggestion list

If Tab is inserting snippet expansions when you just want indentation, set editor.tabCompletion to "off".

Fix 4: Check for Extension Conflicts

Installed extensions can rebind the Tab key. Common offenders:

ExtensionTab BehaviorFix
Vim / NeovimTab mapped to Vim commandsCheck extension keybindings
TabOutTab jumps out of bracketsDisable or configure tabout.enable
Bracket Pair ColorizerCan interfere in some versionsUpdate or remove
IntelliCodeTab accepts AI suggestionsSet editor.inlineSuggest.enabled
GitHub CopilotTab accepts AI completions"editor.inlineSuggest.enabled": false to test

How to diagnose:

  1. Open Command Palette (Ctrl+Shift+P)
  2. Type "Developer: Open Keyboard Shortcuts (JSON)"
  3. Search for "tab" to see all Tab key bindings
  4. Look for conflicting bindings from extensions

Or disable all extensions and re-enable them one at a time:

bash
# Launch VS Code with all extensions disabled
code --disable-extensions

If Tab works with extensions disabled, enable them one by one to find the culprit.

Fix 5: Tabs vs. Spaces Configuration

If Tab inserts spaces instead of a tab character, this is by design. VS Code defaults to inserting spaces. To change it:

json
1{
2    "editor.insertSpaces": true,
3    "editor.tabSize": 4,
4    "editor.detectIndentation": true
5}
SettingDefaultWhat It Does
editor.insertSpacestrueTab key inserts spaces (not \t character)
editor.tabSize4Number of spaces per Tab press
editor.detectIndentationtrueOverrides above settings based on file content

Quick toggle: Click the "Spaces: 4" or "Tab Size: 4" indicator in the bottom status bar to switch between tabs and spaces for the current file.

Note that editor.detectIndentation can override your settings on a per-file basis. If a file already uses tabs, VS Code switches to tabs for that file even if your default is spaces.

Fix 6: Check Keybinding Conflicts

To see exactly what the Tab key is bound to in your current context:

  1. Open Keyboard Shortcuts (Ctrl+K Ctrl+S)
  2. Click the "Record Keys" button (keyboard icon)
  3. Press Tab
  4. See all commands bound to Tab and their "when" conditions

You can also check via the Command Palette:

 
Developer: Toggle Keyboard Shortcuts Troubleshooting

After enabling this, press Tab and check the Developer Tools console (Help > Toggle Developer Tools) to see which command won and which were suppressed.

Resetting Tab to default behavior

If nothing else works, you can explicitly define the Tab key behavior in keybindings.json:

json
1[
2    {
3        "key": "tab",
4        "command": "tab",
5        "when": "editorTextFocus && !editorTabMovesFocus"
6    },
7    {
8        "key": "tab",
9        "command": "editor.action.indentLines",
10        "when": "editorTextFocus && editorHasSelection && !editorTabMovesFocus"
11    }
12]

Fix 7: Reset VS Code Settings Entirely

As a last resort, reset all settings to defaults:

  1. Open Command Palette (Ctrl+Shift+P)
  2. Type "Preferences: Open User Settings (JSON)"
  3. Delete all content (or back it up first)
  4. Save the file

Or reset from the command line:

bash
1# Back up current settings
2cp ~/.config/Code/User/settings.json ~/.config/Code/User/settings.json.bak
3
4# Reset to empty
5echo "{}" > ~/.config/Code/User/settings.json

On macOS, the settings file is at ~/Library/Application Support/Code/User/settings.json. On Windows, it is %APPDATA%\Code\User\settings.json.

Diagnostic Checklist

Run through this list in order when Tab stops working:

  1. Check status bar for "Tab Moves Focus" indicator. If present, press Ctrl+M.
  2. Test with extensions disabled: code --disable-extensions.
  3. Open Keyboard Shortcuts, record Tab key press, check for conflicts.
  4. Check editor.tabCompletion and emmet.triggerExpansionOnTab settings.
  5. Look for editor.tabFocusMode in your settings.json.
  6. Check workspace settings (.vscode/settings.json) which override user settings.
  7. If nothing works, reset settings to defaults.

Common Pitfalls

  • Hitting Ctrl+M accidentally. This is the number one cause. Ctrl+M is right next to common shortcuts (Ctrl+N, Ctrl+B), and there is no visual confirmation dialog when toggling it. Train yourself to check the status bar.
  • Workspace settings overriding user settings. Your project's .vscode/settings.json takes precedence over your user settings. Check both files when troubleshooting.
  • Confusing "Tab key does nothing" with "Tab inserts spaces". If your file is set to use spaces, Tab works correctly but inserts invisible space characters instead of a visible tab character. Check the status bar for "Spaces" vs "Tabs".
  • GitHub Copilot taking over Tab. When Copilot shows a ghost suggestion, Tab accepts the suggestion instead of indenting. Press Escape to dismiss the suggestion first, then Tab will indent as expected.

Summary

  • The most common fix is pressing Ctrl+M to toggle off "Tab Moves Focus" mode.
  • Check emmet.triggerExpansionOnTab and editor.tabCompletion settings if Tab triggers expansions instead of indentation.
  • Use code --disable-extensions to isolate extension conflicts.
  • Use the Keyboard Shortcuts Troubleshooting mode to see exactly which command responds to Tab in your current context.
  • Check both user settings and workspace settings (.vscode/settings.json) since workspace settings override user settings.
  • When Tab inserts spaces instead of tab characters, that is the default VS Code behavior, not a bug. Change it with editor.insertSpaces: false if you need actual tab characters.

Course illustration
Course illustration

All Rights Reserved.