tabWidth ignored in VS Code and .prettierrc
See original GitHub issueMy full setting overwrites are
{
"sublimeTextKeymap.promptV3Features": true,
"prettier.trailingComma": "es5",
"prettier.tabWidth": 2,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"[javascript]": {
"editor.formatOnSave": true
}
}
But formatting still gives me a tab width of 4.
The only extensions I currently have installed are vscode-styled-components, Sublime Text Keymap, and Prettier - Code formatter.
I have tried running prettier on a .js file in an otherwise empty directory and it behaves as it should, indenting with 2 spaces, but the problem persists in multiple projects.
In an attempt to override whatever is causing this I have added a .prettierrc file at the top level of a project with the contents
{
"tabWidth": 2
}
But that hasn’t worked either.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Unable to set tab width to 4 in prettier - Stack Overflow
First, remove any .prettierrc from the working directory. Because it overrides user settings and uses the default values.
Read more >Options - Prettier
Setting indent_size or tab_width in an .editorconfig file will configure Prettier's tab width, unless overridden. Tabs. Indent lines with tabs instead of spaces ......
Read more >Basic Editing in Visual Studio Code
Learn about the basic editing features of Visual Studio Code. Search, multiple selection, code formatting.
Read more >How to configure Prettier and VSCode - Gleb Bahmutov
How to set up Prettier, ESLint and VSCode per project and have your JavaScript ... Print width; Ignoring files; Saving without formatting ...
Read more >vscode prettier ignore not working - You.com | The AI Search ...
prettierrc or .editorconfig) detected, falling back to VS Code configuration ["INFO" - 23:32: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Wow, I had a .editorconfig in the directory above my project. I’m not sure why that would override .prettierrc and I’ve no idea where it came from, but I’ve edited it now and Prettier is indenting as expected.
Thanks for your help, that was driving me mad.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.