Tabs to Spaces Package


#1

Continuing the discussion from Change tabs to spaces:

Because people were asking for it and because I thought it would be simple, I created a package that converts leading tabs to spaces in an open file:

It is bare bones at the moment, just using your editor.tabLength configuration setting to decide how many spaces to replace a tab character with. I did my best to just do a simple conversion, but please file a bug if there is an edge case I didn’t think of.

Plans:

  • Convert spaces to tabs (if you really wanna, I guess)
  • Make menu titles and commands easier to read and find — probably use “untabify” and “tabify”
  • Convert only within a selection or selections, rather than a whole file

Change tabs to spaces
#2

Awesome mate!
Thanks.


#3

As requested by @mattma, updated to add the “Tabify” command, convert spaces to tabs.


#4

@leedohm It works as advertised. Awesome. As a first group of tester, i want to ask for another quick request. If I want to bind with a keyboard shortcut on it, do you have a code snippet for that?

In sublime, what I do is using ctrl-. :slight_smile: Thanks


#5

[@mattma Moved your post because this is more the place to talk about the package itself… :smile: ]

Yes, you can open your keymap.cson and add the following:

'.editor:not(.mini)':
  'ctrl-.': 'tabs-to-spaces:tabify'

#6

When you mention that your really “wanna spaces to tabs”, you think spaces win over tabs? I know it is a big long topic. lots of posts list pro and con about which one over the other one. For me, it simply looks better in tab with my custom font of my choice.

Thanks for your quick reply. I promise i won’t bother you again tonight. hahahah…


#7

I know that I’m not going to solve the debate for everyone, but my personal feelings on the topic essentially boil down to there is no one right way to handle a TAB character. There is only one right way to handle a SPC character.

With that said, I know that there is the occasional use of tabs instead of spaces, so I wanted to add the functionality whether or not anyone was going to use it specifically.


#8

@leedohm Maybe I lied. In sublime, I could bind one keyboard shortcut ctrl-. as toggle feature, I tried with your keymap, it works great. I did something like these

'.editor:not(.mini)':
    'ctrl-.': 'tabs-to-spaces:tabify'
    'ctrl-.': 'tabs-to-spaces:untabify

It did not work. Well, then i tried this,

'.editor:not(.mini)':
    'ctrl-.': 'tabs-to-spaces:tabify'

'.editor:not(.mini)':
   'ctrl-cmd-.': 'tabs-to-spaces:untabify'

only the untabify works, but not tabify. The ideal solution is, using the ctrl-. to toggle it. :slight_smile: i think it may be a feature request.


#9

Yeah, I suspected that might be what you were asking for. The key is figuring out which direction the user wants to go without scanning the whole file. I suppose if I get it wrong, they can always just hit the key again :laughing:

I’ll see what I can do but it probably won’t be tonight.


#10

No hurry. command palate works great. I am sure that I could survive until the 0.3.0 release. Thanks for your hard work. Looking forward for your next great plugins.

I am a full stack js dev with great knowledge on coffeescript too, that is why I switched from Sublime (python) to Atom ( coffeescript). I am sure that I will start to develop some plugins for people’ need.

Where is the good starting point for writing a plugin? splitting_atom ? How do you get started?


#11

I didn’t know about splitting atom until you just linked it. I basically just started with the API documentation and the Generate Package command and fiddled around from there.


#12

hi,

Sorry but I can´t get this to work. I installed it and pressed -untabify all- in the menu, but nothing happened. I also tried with highlightning all first. Tabs still tabs. Can the Atom beautifyer package have something to do with it?