Everyday Toolkit

VS Code Indentation Shortcuts on Mac: Keybindings, Settings, and Formatting

Published 2026-07-28

Updated Jul 2026

Some links on this page are affiliate links. If you buy through them we may earn a small commission at no extra cost to you. We only recommend what we'd use.

Key takeaways
  • Master default Mac shortcuts like Cmd+] and Cmd+[
  • Customize keybindings to fit your muscle memory
  • Configure tab size and spaces in settings
  • Fix mixed indentation and formatting conflicts
VS Code Indentation Shortcuts on Mac: Keybindings, Settings, and Formatting
Photo: JackPotte (Dirk Hünniger (LaTeX Version)) via Wikimedia Commons

VS Code Indentation Shortcuts on Mac: Keybindings, Settings, and Formatting

The primary default shortcut to indent a line or highlighted block in VS Code on Mac is Cmd + ], while Cmd + [ outdents it. Learning these keybindings alongside workspace settings saves you from tedious manual spacing and messy git diffs. This guide covers native Mac shortcuts, configuration options, and practical fixes for formatting glitches.

Understanding Indentation in VS Code

Indentation in VS Code structures code blocks so the editor and your team can easily parse logic hierarchies. By default, the editor handles indentation using language rules, auto-detecting whether a file uses tabs or spaces, but mismatched settings can quickly break formatting across different editing environments.

When you open a file, VS Code scans the existing content to determine line spacing. While this works well most of the time, working in shared repositories often introduces conflicting indentation styles. Understanding how VS Code handles line spacing under the hood makes it much easier to keep your code clean, readable, and consistent across your entire project.

Default Indentation Shortcuts on Mac

Shift code right in VS Code on macOS using Cmd + ] and shift code left using Cmd + [. Pressing Tab indents a highlighted block, while Shift + Tab outdents it, giving you two native ways to align blocks cleanly without tapping spacebar repeatedly.

Here is how these default keys function during daily editing on macOS:

  • Cmd + ] (Indent): Moves the active line or selected block one step to the right based on your active tab size settings.
  • Cmd + [ (Outdent): Shifts the current line or selected block one step to the left.
  • Tab: Indents selected text or inserts a tab character at the current cursor location.
  • Shift + Tab: Outdents selected text or shifts the current line back one indentation level.

Customizing Indentation Shortcuts

Rebind your indentation keys by pressing Cmd + K, Cmd + S to open the Keyboard Shortcuts menu, then searching for "Indent Line" or "Outdent Line." Double-click the command you want to change, press your preferred key combination, and hit Enter to save the new keybinding instantly.

If you prefer directly editing configuration files, you can add custom keybindings to your keybindings.json file. This approach lets you set up conditional bindings—such as enabling specific shortcuts only when editing Python or YAML files—giving you total control over how your editor responds.

Spaces vs. Tabs: Configuration is Key

Open settings with Cmd + , and search for "Tab Size" and "Insert Spaces" to set your preferences. Turning on "Insert Spaces" converts tab keypresses into fixed space characters, ensuring your code looks identical across various text editors, code reviews, and continuous integration pipelines.

You can also adjust these options visually without diving deep into the settings menu. Look at the bottom right corner of your VS Code window on the status bar. Clicking on the entry that says "Spaces: 2" or "Tab Size: 4" opens a dropdown where you can convert indentation types on the fly for the current file.

Troubleshooting Indentation Issues

VS Code Indentation Shortcuts on Mac: Keybindings, Settings, and Formatting
Photo: JackPotte via Wikimedia Commons

Indentation glitches usually happen when editor.detectIndentation overrides your user preferences or when conflicting extensions auto-format on save. Disabling auto-detection, running "Reindent Lines" from the Command Palette, or toggling whitespace rendering typically fixes alignment errors when switching between shared repositories.

When indentation acts up, work through these diagnostic checks:

  • Disable Auto-Detection: Set "editor.detectIndentation": false in your user settings if VS Code keeps switching your tab size unexpectedly.
  • Render Whitespace: Turn on "editor.renderWhitespace": "selection" or "all" to make dots (spaces) and arrows (tabs) visible so you can spot mixed formatting immediately.
  • Check Extension Conflicts: Extensions like Prettier or language-specific formatters can override native settings. Verify which tool is set as your default document formatter.

Advanced Indentation Techniques

Advanced line control relies on multi-cursor editing with Option + Cmd + Up/Down arrow keys and full-document formatting via Option + Shift + F. Combining these features with native selection tools lets you refactor deeply nested structures across dozens of lines in seconds without manual alignment.

For more control over complex files, try these workflow enhancements:

  • Format Selection (Cmd + K, Cmd + F): Applies your configured indentation and style rules only to the lines you have actively selected.
  • Reindent Lines Command: Open the Command Palette (Cmd + Shift + P), type "Reindent Lines", and press Enter to recalculate spacing for the entire file based on language syntax rules.
  • Multi-Cursor Alignment: Hold Option while clicking different lines to place multiple cursors, allowing you to insert or delete indent spaces simultaneously.

Comparison of Indentation Tools & Methods

Native VS Code shortcuts handle quick line adjustments, while tools like Prettier and EditorConfig enforce uniform rules across entire engineering teams. Selecting the right approach depends on whether you need manual control over local snippets or automated workspace enforcement across multiple project repositories.

Tool / Method Best For Setup Effort Key Benefit
Native Shortcuts (Cmd + ]) Quick, manual line shifts while writing code None (Built-in) Instant feedback, zero setup required
Prettier Extension Automated opinionated formatting on save Low (Extension install) Eliminates style arguments across teams
EditorConfig (.editorconfig) Enforcing baseline settings across different editors Medium (Project config file) Works across VS Code, JetBrains, and Vim

🛍 Ready to buy? Check current prices on Amazon for the picks in this guide.

Recommended Approach:

  1. Native Shortcuts: Best for daily active typing and quick structural edits within single blocks.
  2. EditorConfig: Essential for open-source and team projects to enforce base spacing across different text editors.
  3. Prettier: Ideal for larger web development workflows where automatic format-on-save keeps code pristine.

Common Pitfalls and Solutions

Common pitfalls include mixing spaces and tabs in a single file, relying on auto-detection in legacy codebases, and failing to configure language-specific overrides. Fixing these requires setting clear global tab rules, enabling visible whitespace, and adding repository settings to prevent local developer configuration drift.

Here are three frequent traps and how to handle them quickly:

  • Mixed Tabs and Spaces: Running into syntax errors in whitespace-sensitive languages like Python often stems from invisible tab/space mixing. Use the Command Palette to run "Convert Indentation to Spaces" to fix the entire file.
  • Global vs. Workspace Conflicts: Global user preferences can easily overwrite project conventions. Save dedicated project preferences inside a .vscode/settings.json file at the root of your repository to keep everyone aligned.
  • Language-Specific Overrides: Front-end projects might require 2-space indentation for HTML/JSON but 4 spaces for Python. Add language-specific blocks in your settings.json to apply separate spacing rules automatically.

Managing Indentation Across Teams

Establishing unified formatting configurations keeps codebases clean when multiple developers commit changes from different operating systems. Combining workspace-level settings files with explicit repository formatting rules ensures everyone's local editor handles line spacing identically, eliminating noisy Git diffs during pull requests.

To set up an ideal environment for team projects, check a .vscode/settings.json file directly into version control. Include key directives like "editor.tabSize": 2, "editor.insertSpaces": true, and "editor.formatOnSave": true. When team members clone the repo, VS Code automatically respects these local project rules regardless of their personal global defaults, keeping every pull request clean and readable.

FAQ

How do I change the indentation size in VS Code on Mac?

Press Cmd + , to open Settings, type "Tab Size" into the search bar, and select your preferred number of spaces (typically 2 or 4). You can also click the "Spaces" or "Tab Size" display in the bottom status bar to adjust it on the fly for your current file.

Why is my code not indenting correctly in VS Code?

Misaligned code usually results from conflicting extensions, mixed tab and space characters, or VS Code auto-detecting settings from an old file. Try disabling editor.detectIndentation in your settings, or run Cmd + Shift + P and select "Format Document" to force alignment.

Can I create custom indentation shortcuts in VS Code?

Yes. Open the Keyboard Shortcuts menu with Cmd + K, Cmd + S, then search for "Indent Line" or "Outdent Line." Double-click the command, press your custom key combination on your Mac keyboard, and press Enter to lock in the new keybinding.

What is the difference between tabs and spaces in VS Code?

Tabs insert a single tab character whose width depends on editor settings, whereas spaces insert a fixed set of individual space characters. Most teams prefer spaces because they render identically across every text editor, code review tool, and terminal display.

How do I format an entire file at once on a Mac?

Press Option + Shift + F on your Mac keyboard. This triggers the built-in document formatter (or an extension like Prettier), instantly re

🛍 See today's best prices on Amazon and grab the option that fits you.

Editorial Team Author & reviewer

Hands-on reviewers testing tools, apps and services so you do not have to. Every article here is hands-on tested and human-reviewed before publishing.