Sublime Forum

Indentation level different than tab_size


Hi!, does someone know a way to specify an indentation level different than tab_size?

For example, I indent C++ files with 2 spaces, but when I reach 8 spaces I replace them with one tab of 8 chars (tab_size=8). I cannot find an “indentation_size” option or something similar to “tab_size” that represent the indentation level in spaces and instead of tabs.

I think that there are some options missing here (or that I didn’t find):

  • indentation_size (integer): number of spaces to use for indent code, which is not the same as “tab_size”

  • compress_spaces_with_tabs_on_indentation (boolean): to specify that spaces should be converted to tabs when you reach a certain level of indentation (e.g. 8 spaces compressed to 1 tab if tab_size=8)



Very original way to indent source code…

What’s the purpose ?



Backward compatibility with the current way I’m indenting code. Right now I’d prefer to use all spaces (2 spaces for indenting, without tabs). But if you are working in a project that use this kind of (simple) indentation scheme, you should be able to specify: tabs width = 8 and indent level = 2, it doesn’t look something so crazy.

PS: Historically tabs were 8 chars long, so having tab_size = 8 and an indent size < 8 is pretty common.



Very original way to indent source code…[/quote]

Not that original. This is mandated by the GNU coding standard and used in all GNU projects. I believe it is also used in the Linux kernel. But I agree it is a weird way of formatting code.



Revival - me too. Indent using 2 spaces, but a TAB character must take up 8 columns. Bonus is to automatically replace 8 spaces with a single TAB (if I then use backspace I would expect it to delete that one TAB char, going back 8 columns).

The GNU 2-space indentation 8-char-tab style is something I recently had to start dealing with. I find it horrible (kernel style is somewhat more acceptable), but the point is the style is there and GNU is older than I am so I will stick to it when I’m supposed to.



Just found a plugin (not tried it yet):

And it links to a newer topic:



Be careful with such kind of plugins. Most of them are quite old and might brake more recent features and functions of ST3, which might result in unwanted/unpredictable results. I didn’t find any, which worked seamlessly.

1 Like