Sublime Forum

Questions about settings

#1

I’ve just started using ST3 and it’s pretty good, but I’ve been running into a few problems. I’m not sure how much of this is bugs and how much of this is misconfiguration, so I thought I’d just ask here. (build 3114)

Settings aren’t applied to existing tabs

When I change settings, they aren’t applied to existing tabs. This is most obvious with color schemes where the new scheme doesn’t take effect until I close and reopen a file, but more insidious and annoying when it’s indentation settings. (The settings aren’t even applied on restarting ST3, only on closing and reopening the file)

This will be a massive pain if I decide to change a setting while I have numerous large workspaces open, so I’d like to know if this is expected behaviour.

Indentation issues

  • I can’t insert a literal tab on an empty line. This regex in the config is wrong (* should be +):
    { "keys": ["shift+tab"], "command": "unindent", "context":
        [
            { "key": "preceding_text", "operator": "regex_match", "operand": "^[\t ]*" }
        ]
    },
  • With detect_indentation false all files default to tab mode - I’d like them to default to spaces mode.

    • I could use translate_tabs_to_spaces except this option also makes it impossible to insert a literal tab, as it’s turned into spaces immediately (Even via copy paste)
    • Is there an undocumented option to set default indentation mode explicitly?
  • I’d also like indent changes to automatically change all of the indentation on that line to the currently chosen one. If I’m going to change the indentation it might as well prevent a mixture of tabs and spaces. Can this be done by tweaking keymap settings?

Other things

  • Is it possible to close open files with a middle click in the sidebar?

  • Is it possible to hide files/folders from the sidebar like with folder_exclude_patterns without disabling it’s indexing?

  • Is it possible to show the current scope in the stat bar? (Like in the ST2 only plugin Current Scope - notice that it’s the code scope not the editor scope: Classname::methodName)

1 Like

Please add a real indent with spaces mode
#2

A lot of settings are view specific and not global, so this is expected behavior. Presumably sublime doesn’t apply a newly changed setting to existing views because it doesn’t keep track of where and how the setting was last changed, which could be due to settings file, menu command, plugin, etc.

I believe it’s also expected that this persists across sessions (e.g. if you have hot_exit turned on, which it is by default) because part of the session that’s saved is the settings as they apply to each open view.

Using the Sublime API you could create a plugin that walks all of the windows and all of the views within each window and modifies settings, though.

1 Like

#3

If anyone’s interested, here’s a hack to fix tab insertion:

    {
        "keys": ["shift+tab"],
        "command": "chain",
        "args": {
            "commands": [
                ["toggle_setting", {"setting": "translate_tabs_to_spaces"}],
                ["insert", {"characters": "\t"}],
                ["toggle_setting", {"setting": "translate_tabs_to_spaces"}],
            ]
        },
        "context": [
            { "key": "setting.translate_tabs_to_spaces", "operator": "equal", "operand": true }
        ]
    },

Basically it uses the Chain of command plugin to disable the setting, execute the command, then re-enable it.

Getting this to work across all forms of pasting, duplication, snippets etc would require basically copy pasting the entirety of your default shortcuts file, then going through and adding these to any command that might result in a tab character.

So it’s horribly impractical. I’d much rather a real option for indentation to produce spaces instead…

I’m also seeing indentations with preceding tabs have incorrect tab stops. It sees 2 characters so indents by 2 spaces, not realizing that they were tabs. This too would be remedied by a proper “Indent with spaces” option that would convert the indentation to spaces before indenting.

0 Likes