# Code Snippets

In the Script Editor you can use and create code snippets, which are small blocks of reusable code that you can insert where you need it in your code.

Using code snippets:
To use a snippet, pick it from the drop-down menu.
Alternatively, type the name of a snippet (or place the cursor at the end of already existing one), then press the Tab key to expand it.
Example: to create the while loop, type "while", then press the Tab key:

Creating new code snippets:
Code snippets are plain text files stored in [GZDB]\Snippets\[category], so just create a new text file there and add the code you want to it.
There are several special tokens you can use:

- [EP] (Entry Point) - that's the place where the cursor will be placed after inserting a snippet.
- [LB] (Line Break) - these will be converted to line breaks when "Allman-style bracing in snippets" (located in Preferences -> Appearance -> Script Editor) setting is enabled, or a space character when it's not.

Warning: snippet's file name must not contain spaces.

Creating new code snippets for custom scripting configurations:
To add snippets to a scripting configuration, which doesn't already have existing snippets ("Insert a Code Snippet" drop-down is disabled in the Script Editor), you'll have to:

1. Add a new folder inside of "Snippets" folder (for example, "[GZDB]\Snippets\Decorate").
2. Add the "snippetsdir" parameter to a scripting configuration, in which you want to use snippets, and set it to the folder name you've just created (for example, snippetsdir = "Decorate";).
3. Add the snippets to the folder you've created.