Copy the below code and save it as generate_uuid.py and put it in ST2's Packages/User directory (Sublime Text 2 > Preferences > Browse Packages... > User).
- Code: Select all
import sublime_plugin
import uuid
class GenerateUuidCommand(sublime_plugin.TextCommand):
def run(self, edit):
u = str(uuid.uuid4())
for r in self.view.sel():
self.view.replace(edit, r, u)
I've added this to my User Key Bindings (Command-Shift-u on a Mac):
- Code: Select all
{ "keys": ["super+shift+u"], "command": "generate_uuid" }