+1

tab size vs indent size?

Brandon Fosdick 11 years ago updated by Alexander Blach (Developer) 11 years ago 3

I'm looking for a simple text editor that knows the difference between tab size and indent size and, ideally, can prefer tabs over spaces. ST2/3 and TextMate2 don't seem to be up to the task. Can Textastic do what I want?

Here is a screenshot of the preferences window:




The tab width is used for indentation. If you enable "Soft tabs", spaces will be inserted when you press the tab key.


Can you tell me how you think it should work for source code files? When tabs are used for indentation, isn't the indentation size the same as the tab size? 

Thanks for the reply.

 

Tab size is equal to indent size when tabs are used for indentation, but that's not always the case. There's a lot of old code (and some new code) that assumes that tab characters are always 8 columns wide (as they should be), regardless of indent size. When viewing, or editing, those files you need some way to set the tab size back to 8, while keeping the proper indent size setting. Otherwise, the code becomes an unreadable mess.


In particular, the GNU style guide requires mixed space-tab indenting (or used to; I haven't looked in awhile), which is where the "prefer tabs over spaces" setting comes in. For example, in the case where indent size is 4, then the first level is indented with 4 spaces, the second with a single tab, the third with a tab and 4 spaces, and so on. Working with such files is a royal pain in any editor that doesn't support different tab and indent sizes.


Xcode handles all of this properly, so here's a screenshot of it's settings. I'm looking for something with the same functionality, but lightweight enough to be my default text editor.



Thanks for the explanation. I just played around with the settings in Xcode and now I see how it works. 


I'll consider adding support for this in a future update. Let's see if this feature is going to be requested by other users as well.