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

VS Code Tab key not working (does not insert a tab)

Codemia Knowledge Hub ·

When the Tab key stops inserting tabs in VS Code, "Tab Moves Focus" mode is usually turned on. Press Ctrl+M (or Ctrl+Shift+M on macOS) to toggle it off. If that does not help, a setting or extension is probably hijacking Tab; the causes and fixes are below.

Turn off Tab Moves Focus (most common cause)

"Tab Moves Focus" is an accessibility feature that makes Tab cycle between UI elements (sidebar, editor, terminal, etc.) instead of inserting whitespace.

How to tell: the status bar at the bottom of VS Code shows "Tab Moves Focus" while it is active.

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"

It is often toggled by accident because Ctrl+M is easy to hit. To keep it off in settings:

json
{
    "editor.tabFocusMode": false
}

Disable Emmet Tab expansion

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

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

Fix:

json
{
    "emmet.triggerExpansionOnTab": false
}

Emmet still works afterward; expand abbreviations with Ctrl+Space or the suggestion menu instead of Tab.

Tab completion and suggestion settings

Tab can also accept autocomplete suggestions and cycle through snippet placeholders, which conflicts with indentation.

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

If Tab expands snippets when you only want indentation, set editor.tabCompletion to "off".

Extensions that rebind Tab

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

To find the conflict:

  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 start with every extension disabled:

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

If Tab works then, re-enable extensions one at a time to find the culprit.

Tab inserts spaces instead of a tab character

This is the default, not a bug: VS Code inserts spaces. The relevant settings:

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

Set editor.insertSpaces to false if you need real tab characters. To switch just the current file, click the "Spaces: 4" or "Tab Size: 4" indicator in the status bar.

editor.detectIndentation can override your settings per file: if a file already uses tabs, VS Code uses tabs for it even when your default is spaces.

Finding which command Tab is bound to

  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

Or enable troubleshooting mode from the Command Palette:

 
Developer: Toggle Keyboard Shortcuts Troubleshooting

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

Restoring the default Tab binding

If nothing else works, define Tab explicitly 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]

Resetting VS Code settings (last resort)

  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 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 ~/Library/Application Support/Code/User/settings.json; on Windows it is %APPDATA%\Code\User\settings.json.

Checklist when Tab stops working

  1. Check the status bar for "Tab Moves Focus". If present, press Ctrl+M.
  2. Test with extensions disabled: code --disable-extensions.
  3. Open Keyboard Shortcuts, record a Tab press, check for conflicts.
  4. Check the 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.

Easy-to-miss causes

  • Accidental Ctrl+M. The top cause. It sits next to common shortcuts (Ctrl+N, Ctrl+B) and toggles with no confirmation, so check the status bar.
  • Workspace settings. A project's .vscode/settings.json takes precedence over user settings, so check both.
  • "Does nothing" vs. "inserts spaces." In a file set to spaces, Tab works but inserts invisible spaces. The status bar shows "Spaces" or "Tabs."
  • GitHub Copilot ghost text. While a suggestion is showing, Tab accepts it instead of indenting. Press Escape to dismiss it first.

Course
Intermediate
27 lessons
14 hours
OOD Fundamentals

Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.

View the course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms