Reputation: 2388
Before
After
Before:
"translate_tabs_to_spaces": true,
"line_padding_bottom": 2,
"line_padding_top": 2,
"font_face": "microsoft yahei",
"font_size": 11,
After
"font_face": "microsoft yahei",
"font_size": 11,
"line_padding_bottom": 2,
"line_padding_top": 2,
"translate_tabs_to_spaces": true,
After the file is saved auto order by alphabetically.
why?
Upvotes: 0
Views: 220
Reputation: 16085
This behavior occurs when Sublime Text or a plugin alters the main preferences file. For example, changing a color scheme via the Preferences > Color Scheme
menu will cause this.
This has been reported on the forums for ST2, but still affects ST3.
Basically it happens because JSON does not have support for comments in the specification. ST allows them because it is stripping them before pulling them into a structure. Therefore, when preferences are altered by a plugin or ST itself (i.e. not edited by hand), whatever is in the file is disregarded and the structure is just dumped back to the file in alphabetical order.
This can be avoided by only ever manually changing the preferences file. i.e. not using the menu and not installing any plugins which will modify it...
To work around the comments disappearing, don't use comments! If you want to put a note next to the tab_size
setting for example, write it as a value for key tab_size_comment
. That way, when the file is sorted, the note will stay near the relevant setting, and it won't be stripped because it is a proper key-value pair, and not a comment. Usually, there is no effect of setting an unknown key.
Example:
"tab_size": 2,
"tab_size_comment": "some description about tab_size"
Upvotes: 1