Home Download Buy Blog Forum Support

Does Sublime destroy indentation of file?

Does Sublime destroy indentation of file?

Postby outLiner on Thu Sep 26, 2013 2:10 am


I'm new to sublime text 2 and having really nice time with it.

But, recently, I heard some bad news that Sublime destroys the current indentation of file. ( HTML or Javascript and so on)

What I mean is "not" Sublime is fail to indent file.

Before I met Sublime, I used Vim editor for html , javascript editing.

And the files that I edited with Vim have some special indenting rules. ( Let's say it's not standard but my custom.)

The problem occurs at this point.

Someone said that if I open the file (which is indented with my custom rule) with Sublime,

then Sublime destroys the original indenation of the file and re-format the file for Sublime.

But, actually, I just heard that and couldn't see if it's true until now.

Is Sublime really works like that?

This is really sensitive problem for me because I should keep the custom indentation of original files.

Thank you for reading.
Posts: 1
Joined: Thu Sep 26, 2013 1:57 am

Re: Does Sublime destroy indentation of file?

Postby qgates on Thu Sep 26, 2013 4:28 pm

In short: No.

Config option "detect_indentation", when set true, will attempt to detect from a loaded file whether the tab key should insert spaces or tabs, and what the tabstop size should be. Setting this option to false will disable that behaviour. Even when set true this option should not affect the existing whitespace in the file.

If another editor was used to create files using tab characters for indenting, and tabstops of (say) 8 characters, and sublime is set to tabstops being 4 characters, the file will look different in sublime even though it's content is unchanged. This can be rectified simply by setting tabstops to be the same as the editor you were using.

The only options that will remove/change whitespace are options like "trim_trailing_white_space_on_save", which in any case will only affect the file on save. AFAIK, at load time files content are never changed.

Related points:

- Sublime does not presently support variable tabstops. Tabstops will always be equidistant at a configurable set width. So for example if you want tabstops at position 5, 20, 28 and then every 5 characters afterwards that's not currently possible. I've been asking for this feature for quite a long time, since it makes transitioning from other editors much easier - keeping code correctly formatted on-screen - and also allows sublime to be used in workplaces that use other editors and define variable tabstops as part of their in-house coding guidelines.

- I'd like to see a hybrid mode for use of the tab key, where it inserts tabs when there's nothing else since the beginning of the line, or spaces otherwise. Tab chars play havoc with inline commenting, but work lovely for representing code flow. This could probably be achieved with a little plugin, shortcut and/or macro cleverness, but it'd be nice to see out of the box.

Posts: 277
Joined: Mon Nov 05, 2012 4:33 pm

Return to General Discussion

Who is online

Users browsing this forum: Google [Bot], jfcherng, Yahoo [Bot] and 14 guests