Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tab size wrong with EditorConfig and SublimeText 3

With SublimeText3 my .editorconfig file contains:

[*.{h,cc,cpp}]
indent_style = space
indent_size = 2
tab_width = 8

I would expect tab characters in a file to expand to 8 spaces, but I'm seeing them expand to only 2 spaces. Hitting tab correctly indents by 2 spaces.

Is there a way to make it work as desired? So that tab characters expand to 8 spaces? But hitting tab still inserts 2 spaces?

like image 670
Philip Avatar asked Sep 13 '25 08:09

Philip


1 Answers

That's because you're using indent_style = space and providing indent_size = 2. If you want your tabs to spand 8 spaces, then use indent_size = 8, but I'm pretty sure you don't want that! In this case, since you want to work with tabs, then try this

[*.{h,cc,cpp}]
indent_style = tab
tab_width = 8

(Also its a good practice to check for mixed tabs and spaces in your files, that may lead to incorrect behavior in your config, which may not apply here, but it's a friendly reminder)

like image 187
Frondor Avatar answered Sep 16 '25 07:09

Frondor