Sublime Forum

Snippet token to insert random text

#1

Does anyone know of a way to generate a string of random text/numbers/whatever in a snippet? In other words, I want to have a token $rtext in a snippet such that when I insert that snippet in a document, $rtext gets replaced with some random text. Does such a token exist already?

There are a few plugins out there to generate random numbers, hex codes, lipsum, etc., but these are all triggered by a keyboard shortcut.

Or, can anyone think of a way to combine one of these plugins with the snippet system?

0 Likes

#2

You can’t. You’ll need to generate the random text with a plugin and either insert the snippet in with plugin code as well or integrate it in a macro. You can then trigger the macro using a key binding. You can also make the key binding trigger on tab but only if your caret is preceeded by specific text (using context specifiers).

See this readme for an example.

0 Likes

#3

Thanks, looks like I can make that work!

0 Likes