I would like sublime to save my file on each key stroke, for live reload purposes.
The neatest action would be to autosave on each keystroke, only if the file has valid syntax.
If compass task was fast enough it would be like working directly in chrome inspector.
You could write a plugin that saves the file using the on_modified
listener. Something like the following may work (note untested)
import sublime_plugin
class SaveOnModifiedListener(sublime_plugin.EventListener):
def on_modified(self, view):
view.run_command("save")
If you have a linter, you could validate it, and only save on clean lints. Note that with what I have posted, any edit to any file in sublime will be saved on each keystroke. You may want to add some additional checks for things like file type, if it exist on disk, etc.
I had this very same need some time ago when I was trying to do some very fast feedback prototyping that required the file to be saved before I could analyze its output. However, this is not something I'd need in all my projects.
Luckily I found that there is an elegant plugin that does just what is needed - saves the given file after each and every modification - and does that with a simple addition! You can easily enable and disable the feature when it suits you with a simple key combination. Although it is but a small improvement over the other spot on answer, I hope it'll help someone out there.
The plugin in question is auto-save, and of course, it can be installed through Sublime Package Control.