Hi,
I get auto indent when I press F1 with this key binding:
{"keys": ["f1"], "command": "reindent", "args": {"single_line": false}},
But I need this again & again; how can I have it worked out automatically without hitting any key?
Hi,
I get auto indent when I press F1 with this key binding:
{"keys": ["f1"], "command": "reindent", "args": {"single_line": false}},
But I need this again & again; how can I have it worked out automatically without hitting any key?
You can create this plugin called auto_indent_always.py
on your Packages/User
folder:
import sublime_plugin
class AlwaysAutoIndent(sublime_plugin.EventListener):
def on_modified_async(self, view):
view.run_command( "reindent", {"single_line": False} )
Is it possible to target specific .css files and indent only for “:” symbol?
Yes. Play around with view.settings().get(“syntax”)
and with view.substr(view.sel()[0].begin() - 1)
.
The text that @rwols provided isn’t a direct setting, so adding it to a settings file isn’t going to do anything.
The part with view.settings().get("syntax")
is how you can programmatically ask a file what syntax it’s using; you can compare the result of that file with the name of the CSS syntax to determine if a file is CSS or not.
Similarly, view.substr(view.sel()[0].begin()-1)
is sample plugin code for extracting the character just before the cursor in the current file; you can compare the result of that to see if the cursor is just after a colon to know if the plugin should indent or not.
In order to use either of those, you or someone else will have to modify the sample plugin that @addons_zz provided to allow it to only trigger in the cases that you want instead of all the time.