Smart Tabs Support


#1

In general, indentation schemes have fallen into two categories: “Hard” tabs, and “Soft” tabs. I totally agree with the idea behind soft tabs, but I believe that soft tabs are just as bad as hard tabs when it comes to restricting the end-user’s ability to view code using their own preferences.

I’ve been an avid Emacs user up until, well, today, when I decided to give Atom a shot. The only bone I have to pick is that there is no existing SmartTabs analog—when it comes to indentation, you must use either soft or hard tabs.

To me, Smart Tabs makes more sense than Soft Tabs; the idea is simply that you use tabs for indentation and spaces for alignment. Tabs denote changes in the level of indentation, where spaces will align code beyond that. This is better, IMHO, because the user can change their tab size and it doesn’t matter; the code is still beautiful.

I think Atom should probably support Smart Tabs, either through a package or (even better) internally. Smart Tabs, to me, is the only indentation scheme that actually makes any sense. I’d love to assist in clarification of Smart Tabs to anyone who doesn’t understand me, and I’d sure love to live my life inside of Atom, but I do not want to change my coding style.

I’m also totally open to debating about indentation with people.


Request: SmartTab: HardTabs for indentation, SoftTabs(spaces) for alignment
Is there a tab setting in Atom that preserves the indentation string?
#2

+1



#3

+1

Trying to use smart tabs in Atom as it is now is quite frustrating. The tab settings need much more customizability.


#4

Personally, I feel like it would be much easier if every aspect of code entry (keystroke handling) were scriptable. This would enable packagers to create callbacks for new keybindings and such.


#5

You can create callbacks for keybindings right now. You could even create a package that customizes the behavior of the TAB key … just look at autocomplete-plus.


#6

I’m glad that keys are callbackable, but I’m wondering about packaging this. It would be great if Atom had this functionality built-in. I’m probably not the best person to do the package. Would someone be interested in picking this one up?


#7

Is there a better place to push support/request for this feature/package? I’d love to be able use Smart Tabs in Atom!


#8

I’ve considered hosting a site that listed desired packages and allowed people to add suggestions and vote on the ones they want. It could also list possible candidates that exist but it would require a lot of work to look for the existing packages.

A cool thing is there could be a single search that returns results for existing and non-existing packages.

It wouldn’t affect core but it would give people ideas for packages to develop.


#9

What use would adding existing packages provide? I do my best to search prior to making a request. UserVoice is pretty great, unfortunately they don’t have free plans for open source projects and even the basic plan is a crazy $500/month. Something like that would be pretty good, I think on here it can be quite common for requests to get buried among all the other discussions.


#10

I just crossed the annoyance threshold for working with non-smart tabs, so I wrote an initial implementation of a Smart Tabs package: https://atom.io/packages/atom-smart-tabs

By default I’m not registering any functions to the tab key as I worry it might interfere with other atom features. I need to investigate how to integrate it with things like language grammars, etc. But if you’re brave enough you can map tab and shift-tab to the smart tabs.

Hope it’s useful


#11

What about Elastic Tabstops? It calculates the position of the next tabstop to fit the text between tabs on adjacent lines.

There’s an implementation for Sublime here. Broken, because it inserts spaces followed by a tab, but it’s usable anyway, and doing it that way keep the formatting for other text editors.


#12

Elastic tabstops sounds like an awesome idea. Based on my reading though, it’s just an implementation of the idea behind smart tabs.

If I have time to hack it into my extension I would.