Sublime Forum

Generate UUID

#1

This plugin will generate a UUID (uuid4, to be specific-- if you want to know more, or if you should edit this to use uuid1, read more here) or a series of UUIDs if you have selected multiple points.

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]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)
[/code]

I’ve added this to my User Key Bindings (Command-Shift-u on a Mac):

{ "keys": "super+shift+u"], "command": "generate_uuid" }
0 Likes

#2

Thanks, this is useful.

0 Likes

#3

Very useful, thank you!

0 Likes