Is it possible to create a code snippet or a task runner (or anything else) that would allow me to generate a UUID in VSCode? This question can also be interpreted in a more generic way: Can I run an external tool/program and insert the result at the current cursor position.
Thanks.
UUID was standardized by the Open Software Foundation (OSF), becoming a part of the Distributed Computing Environment (DCE). Different versions of UUID follow the RFC 4122 specification. UUIDs are generated using an algorithm based on a timestamp and other factors such as the network address.
A Version 4 UUID is a universally unique identifier that is generated using random numbers. The Version 4 UUIDs produced by this site were generated using a secure random number generator.
UUID 1 to Generate a unique ID using MAC AddressThe uuid. uuid1() function is used to generate a UUID from the host ID, sequence number, and the current time. It uses the MAC address of a host as a source of uniqueness. The node and clock_seq are optional arguments.
Format. In its canonical textual representation, the 16 octets of a UUID are represented as 32 hexadecimal (base-16) digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 hexadecimal characters and 4 hyphens). For example: 123e4567-e89b-12d3-a456-426614174000.
The following extension is super easy to use and does exactly what you want: https://github.com/heaths/vscode-guid (or get it here from the VS Marketplace)
Regarding code sniper and uuid, consider that VSCode 1.53 (Jan. 2021) introduces an interesting feature:
New Snippet Variables
There are new snippet variables for inserting uuids and for inserting the relative path the current file.
The sample snippet below would print:
let someId = 'foo/test.js/c13d226f-1932-40e2-9fd9-10198c219e33'
// sample snippet using UUID and RELATIVE_FILEPATH { "scope": "javascript", "prefix": "newVars", "body": "let someId = '${RELATIVE_FILEPATH}/${UUID}'$0" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With