Created
December 14, 2012 23:23
-
-
Save Restuta/4289538 to your computer and use it in GitHub Desktop.
Sublime Plugin that does auto-save of the current document when you stop typing. Can be used with LiveReload to remove the need to press Ctrl+S all the time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin, functools | |
class IdleWatcher(sublime_plugin.EventListener): | |
pending = 0 | |
def handleTimeout(self, view): | |
self.pending = self.pending - 1 | |
if self.pending == 0: | |
self.on_idle(view) | |
def on_modified(self, view): | |
self.pending = self.pending + 1 | |
# Ask for handleTimeout to be called in N ms | |
sublime.set_timeout(functools.partial(self.handleTimeout, view), 800) | |
def on_idle(self, view): | |
view.run_command("save") | |
print "Current document saved" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment