Snippets

Snippets Templates

On this settings page you can edit and create frequently used code templates - snippets. Snippets are grouped according to the context where they can be used (usually, by the corresponding language). Snippets defined as PHP ones are accessible only for PHP code, CSS snippets are for CSS code, etc.

Snippets appear in IntelliSense mixed with other suggestions, or you can expand the template pressing Ctrl + Shift + Z hotkey combination. You can change it in Preferences | IDE | HotKeys | Edit | Expand snippet.

[Tip]Tip

By default, more popular code constructions (code phrases) for PHP and JavaScript are accessible.

Creation of snippets

Variables are set by @ symbol. If you need to insert @ sign into snippet text, this sign should be doubled, such as @@.

When the same variable is in several positions of construction, the edition of the variable in any position leads to automate changes in the rest positions to the right of the first changed position.

For example, let’s view For construction:

for($@i (1) = 0; $@i (2) < @cond; $@i (3)++){
    @
}

Variable @i has three positions. If to set the "one" name for the variable in position (1), the same name will be set to the rest variables to the right of the edited one, that is (2) and (3). If you rename the variable in the second occurrence (2) into "onetwo", so the variable in position (3) get the same name.

[Note]Note

More details about snippets: Snippets