Sublime Forum

Automatic space->tab and tab->space conversion

#1

I’m used to using a tabstop of 4sp when coding, and my poor old brain gets confused when people use other indent sizes.

Unfortunately, I’m now working for a company where they use a 2sp indent, and my eyes just can’t see it as an indent. Instead of triggering another round of the tabs vs spaces religious war, I’m trying to find a way to convert spaces back and forth when I load and save a file.

The only way I can think of is to have a plugin that runs when I load a file and automatically converts multiples of 2sp at the start of a line to a tab character, which is set as 4sp wide. Then, to have another plugin that runs when I save the file again, and automatically converts my tabs into 2sp.

Can anyone recommend a collection of settings/plugins that will help me do this without going mad?

0 Likes

#2

You could write your own…

on_load, on_pre_save and on_post_save should do everything you want. You can use the built-in commands codeexpand_tabs[/code].

0 Likes

#3

Thanks for the pointer, adzenith. I’ll see if I can knock something together. The docs look quite amusingly incomplete. :smile:

0 Likes

#4

The unofficial docs fill in some of the gaps:
sublime-text-unofficial-document … e/api.html
Let me know if you need any help!

0 Likes

#5

This isn’t exactly what you’re looking for, but it might help you get started: ExpandTabsOnSave.

0 Likes

Tabs, spaces, and update nags