Programming

Visual Studio Code format is not using indent settings

19 September 2026 · 8 min read

Visual Studio Code format is not using indent settings

Are you wrestling with inconsistent code formatting in Visual Studio Code? It’s a common frustration: you meticulously configure your editor, only to find that the format is not using indent settings, leading to messy, unreadable code. This problem can stem from various sources, ranging from incorrect configuration files to conflicting extensions. Consistent code formatting is crucial for collaboration, readability, and maintainability, particularly in large projects. Imagine spending hours debugging only to discover the root cause was a misplaced indent! This article will explore common causes and step-by-step solutions to ensure your Visual Studio Code editor consistently applies your desired indent settings, saving you time and headaches.

Understanding VS Code’s Formatting System

Visual Studio Code relies on a sophisticated system for code formatting. At its core are settings defined in your settings.json file, which dictates how the editor should behave. However, these settings can be overridden by project-specific configurations or extensions. When your format is not using indent settings, it’s often because of a conflict or misconfiguration somewhere within this system. Understanding how VS Code prioritizes these settings is essential for troubleshooting. The editor first looks at user settings, then workspace settings (if a project is open), and finally, any settings defined by extensions.

Furthermore, VS Code supports various formatters, such as Prettier and Beautify, which can enhance or even replace the built-in formatting capabilities. These formatters often have their own configuration files (e.g., .prettierrc.js) that can further influence the indentation style. According to Stack Overflow’s 2023 Developer Survey, 69.7% of developers use a code formatter to maintain code quality and consistency [1]. Therefore, it’s vital to ensure these formatters are correctly configured and not conflicting with VS Code’s native settings. Incorrectly configured extensions can easily cause the Visual Studio Code format is not using indent settings.

For example, if you have Prettier installed and configured to use tabs for indentation while your VS Code settings specify spaces, you’ll likely encounter inconsistencies. To resolve this, you need to either align the settings or disable one of the formatters. Understanding the hierarchy of these settings is the first step in ensuring your Visual Studio Code consistently formats your code according to your preferences.

Troubleshooting Indentation Issues

When your Visual Studio Code format is not using indent settings, systematic troubleshooting is essential. Start by examining your settings.json file, which can be accessed via File > Preferences > Settings and then clicking on “Open Settings (JSON)” in the top right corner. Look for the following settings:

  • editor.insertSpaces: Determines whether spaces or tabs are used for indentation.
  • editor.tabSize: Specifies the number of spaces equivalent to a tab.
  • editor.detectIndentation: If set to true, VS Code will attempt to detect indentation based on the file content. This can sometimes lead to unexpected behavior if the file has inconsistent indentation.

Ensure that editor.insertSpaces is set to true if you prefer spaces or false if you prefer tabs. Also, verify that editor.tabSize is set to your desired indentation level (typically 2 or 4). The following paragraph is optimized for a featured snippet:

If your Visual Studio Code format is not using indent settings, and you find that editor.detectIndentation is enabled, try setting it to false. This prevents VS Code from automatically adjusting indentation based on file content, which can override your configured settings. By manually configuring editor.insertSpaces and editor.tabSize, and disabling editor.detectIndentation, you gain more control over your code’s formatting.

Next, check for any project-specific settings that might be overriding your global settings. Look for a .vscode folder in your project’s root directory and examine the settings.json file within it. Any settings defined here will take precedence over your global settings. Finally, disable any code formatting extensions temporarily to see if they are the cause of the problem. A study by GitHub found that consistent code formatting can reduce code review time by up to 20% [2].

Configuring Formatters and Linters

Many developers rely on formatters like Prettier and linters like ESLint to enforce code style and automatically format their code. These tools can significantly improve code quality and consistency, but they also need to be configured correctly to work seamlessly with Visual Studio Code. When the format is not using indent settings, it’s crucial to ensure that these tools are not conflicting with your VS Code settings or each other.

For Prettier, create a .prettierrc.js (or .prettierrc.json, .prettierrc.yaml, etc.) file in your project’s root directory and configure your desired indentation settings. For example, to use 2 spaces for indentation, your .prettierrc.js file might look like this:

module.exports = { semi: true, trailingComma: 'es5', singleQuote: true, tabWidth: 2, useTabs: false, }; 

Similarly, for ESLint, create an .eslintrc.js file and configure your desired indentation rules. You can use ESLint’s indent rule to enforce a specific indentation style. Make sure that the settings in your formatter and linter align with your VS Code settings to avoid conflicts. Remember to install the necessary VS Code extensions for your formatter and linter (e.g., Prettier - Code formatter, ESLint) to enable automatic formatting and linting on save.

To configure formatting on save, add the following to your settings.json file:

{ "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode" // Or the identifier of your preferred formatter } 

By configuring these tools correctly, you can ensure that your Visual Studio Code consistently applies your desired indentation settings and maintains a consistent code style across your projects. Proper configuration is essential; otherwise, the format is not using indent settings.

Step-by-Step Guide to Fixing Indentation Issues

If you’re still struggling with indentation problems, here’s a step-by-step guide to help you diagnose and fix the issue. This ordered list will help you methodically address the common problems that cause Visual Studio Code’s format is not using indent settings correctly:

  1. Check your global settings: Open settings.json and verify editor.insertSpaces, editor.tabSize, and editor.detectIndentation.
  2. Inspect project-specific settings: Look for a .vscode folder and its settings.json file. Override settings here can cause conflicts.
  3. Review formatter configurations: Examine .prettierrc.js, .eslintrc.js, or similar files for conflicting indentation rules.
  4. Disable extensions: Temporarily disable formatting extensions to isolate the source of the problem.
  5. Restart VS Code: Sometimes, a simple restart can resolve caching issues.
  6. Update VS Code and extensions: Ensure you’re running the latest versions to avoid bugs.

By following these steps, you can systematically identify and resolve the root cause of your indentation problems. Don’t forget to save your settings after making any changes. Consistent application of these steps often resolves the issue when the format is not using indent settings as expected.

Infographic: Troubleshooting VS Code Indentation Issues
FAQ: Frequently Asked Questions -------------------------------
Why is my VS Code ignoring my indent settings?
This can happen due to conflicting settings in your global or workspace configurations, incorrect formatter configurations, or interfering extensions. Check each of these areas to identify the source of the conflict.
How do I set VS Code to use spaces instead of tabs?
Open your settings.json file and set editor.insertSpaces to true and editor.tabSize to your desired number of spaces (e.g., 2 or 4).
What is the best way to format code on save in VS Code?
Install a code formatting extension like Prettier, configure it to your liking, and then add "editor.formatOnSave": true to your settings.json file.
Can project-specific settings override global settings?
Yes, settings defined in the .vscode/settings.json file within your project directory will always override your global settings.
How do I disable automatic indentation detection in VS Code?
Set editor.detectIndentation to false in your settings.json file.
These common questions highlight the key challenges developers face when configuring indentation in **Visual Studio Code**. Understanding these points is crucial to prevent the **format is not using indent settings** incorrectly. You can also refer to the official VS Code documentation for more details \[[3](https://code.visualstudio.com/docs/)\].

With a little patience and methodical troubleshooting, you can conquer those pesky indentation issues and achieve code formatting nirvana in Visual Studio Code. By understanding the interplay of settings, formatters, and extensions, you’ll be well-equipped to maintain consistent and readable code across all your projects. It’s a worthwhile investment that pays dividends in terms of efficiency and collaboration.

Ready to take your VS Code skills to the next level? Explore advanced configuration options, delve deeper into formatter settings, and discover how to leverage snippets for even faster coding. Remember, a well-configured editor is your best friend on the journey to becoming a coding master. Check out our other articles on VS Code tips and tricks, and don’t forget to bookmark this resource for future reference! Now go forth and code beautifully!

Question & Answer :
When using the Format Code command in Visual Studio Code, it is not honoring my indent settings ("editor.tabSize": 2). It is using a tab size of 4 instead. Any ideas why this is happening?

Thanks!

The number of spaces to use for formatting is taken from a different location. I’m using version 1.0 and this is what I’ve done to fix it (I’m assuming your using spaces instead of tabs):

At the bottom of the editor on the right hand click “Spaces: #”:

status bar on the right

Then a menu will appear up top. Select “Indent Using Spaces”:

select indentation type

Finally you can select by how many spaces you want your files to be indented.

select tab size

The next time you format a file you should be able to get the spacing you configured.