+2

indent-level vs. tab-key vs. tab-character

Garance A Drosehn 6 years ago • updated 6 years ago 2

I'd like to set the size of each indent-level to be 4 characters.  I'd want the tab-character (in a file) to jump to the next 8-character boundary.


I'd expect the tab key (when pressed on the keyboard) to tab to the next indent level (4-characters), not the next tab-character level (8-characters).  I'd want the whitespace on each line to have a tab-character for every 8 spaces needed, followed by 4 more space characters if the indent-level is not a multiple of 8 characters.  This matches a style policy used in the FreeBSD project, for instance.


I can do this with preference settings in XCode, but I don't see how to do the same thing in SublimeText2.  Sorry if I'm just missing something which should be obvious!

Interesting, but feels ever so slightly wrong.  Mixing tabs and spaces is the source of all the hatred us tab-users get and it makes for the most unreadable files whenever someone's indentation widths don't agree with the source code's.


With tabs only, you are free to display them as whatever width your eyes enjoy seeing the code wave along; with spaces, your code looks uniform everywhere across the globe.  With mixed tabs and spaces, the moment someone tries to look with a fully 4 units wide indent length (that is, tab-size), all your indentations start to look messy (0, 4, 4, 8, 8, 12, 12...).


I'm personally quite happy that this broken method isn't supported by Sublime text, only portable ones are.  Sorry to hear that such a great and large project like FreeBSD decided to use such a mess.

We have a few hundred thousand lines of code, and this strategy does not cause a mess.  Like so many things, it's a matter of using it consistently.


I've been using SublimeText2 for a few days now, and really like it a lot.  This issue with tab character vs indents is the only thing which might drive me back to XCode.  I'm not asking anyone else to format their code in any particular way, I just want to configure the editor such that it will automatically format the code in the way I'm expected to format my code.


Maybe I'll have to figure out ST2 plugins to do it.