visual-studio-code

How to generate a UUID in Visual Studio Code?


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.


Solution

  • Unfortunately you can't do it right now with snippets. I don't think it can work via tasks either.

    The only thing I can do for you is to give you a hacky solution that works for C#, TypeScript and Yaml files (tested in VSCode 0.9.0). Let's implement it for TypeScripts to make an example:

    After restarting Code you will always receive in .ts files a suggestion called "Create new UUID" which adds a value like "243BC2A6-1AB5-445B-B086-DBDED67368F5" at the current cursor position. You can force the appearance of the suggestion box by pressing CTRL + Space.

    To add this suggestion to C# and YAML you need to do the same in the corresponding suggestSupport.js files.