Sublime Forum

Bug: Comments deleted in Preferences-User

#1

Hi, I’m a longtime Vim user and I’m currently trying Sublime Text 2 (Version 2.0.1, Build 2217) on a Windows XP SP3 computer. After installing ST2, I edited the Preferences/User file to fit my coding habits and I placed many commented lines in the file, just to be ready to apply some settings simply deleting the comment marks.

As an example, I have:

"font_face": "Anonymous Pro", "font_size": 11, // font_face": "Courier New", // font_size": 10,

Switching font face/body is just a matter of deleting (and insert) some comment marks…

But when I changed the color scheme using the Preferences menu, I got a very annoying surprise:

  1. all comments were deleted :astonished:
  2. all 4 spaces tabs turned to real tabs (notice that I have “translate_tabs_to_spaces” set to “true”)

Anyone experiencing this bug? Any workaround?
Manosk

0 Likes

Don't mess around with the configuration file
#2

Not #2, but I have experienced #1. I suspect it was introduced when sorting the preferences came into being. I first saw it more than a month ago (not sure exactly how long, my preferences don’t change that often), but forgot to post about it.

0 Likes

#3

I imagine this is by design because it is the easiest way to work with the settings because they have a read/write relationship with ST2.

JSON does not have support for comments in the specs. I believe Jon allows them because he is stripping them before pulling them into a structure. More than likely, once comments are removed, the settings file is just parsed into a structure and used by ST2. When preferences are saved by ST2 (not by hand), whatever is in the file is disregarded and the structure is just dumped back to the file in alphabetical order.

It would be a lot of unneeded overhead to try and detect and preserve comments when ST2 reads and writes the preference file for many different reasons.

It would be nice to have comments preserved, but from a coding view point, I understand why they are not preserved. If the preference file had a read only relationship with ST2, then preserving comments would be easy and very much expected.

1 Like

#4

As suggested by facelessuser, ST2 could have an option to lock the Preferences-User file so that it would be editable only by hand.

Anyway, coming from Vim (where I had a virmrc file full of commented lines) this ST2 behaviour is really annoying :angry:

I wonder if someone has found a workaround to manage alternative settings in the Preferences-User file…

0 Likes

#5

I wrote a little post on this exact issue.

http://spacerobots.net/post/30528696290/a-sublime-tip

Basically, just add an underscore to the key of the setting. Works great for me.

0 Likes

#6

**Ouch!! If only I saw this 2 year old post before I used “Package Control” to change themes 20 minutes ago.
**
I just lost all my comments. :blush:

I comment everything because Sublime has so many options I can easily find myself spending more time configuring and looking up options more than I do coding. I just don’t want to remember stuff like the effects of setting the fade_fold_buttons boolean, so I comment it.

     // If you set this to false, it will leave the folding tag to the right instead hiding it.
     "fade_fold_buttons": false,

At first I was cursing Sublime for this bug; then I saw the comments from Douglas Crockford.

Live and learn I guess. Now I need to go find a backup…

0 Likes