0 comment(s).

Chapter 6. Snippets

Table of Contents

Working with snippets
Plain text
Variables
Interpolated local/server code
Tabstops
Placeholders
Mirrors
Transformations

Snippets are pieces of prepared and often used text that is inserted into edited document. They may include things as empty function stub, default HTML page, class declaration and so on. This default behavior acts as code templates, you may know from other editors. But, this is not, by any means, an extent of snippets at all. Snippets are way more capable than that. Please, read on.

Working with snippets

When snippet is inserted, caret may change its position. It is called - going on the first tabstop. Snippets may have up to 9 such positions defined and you can use them by hitting TAB key for moving into the next one. It can often happen, that after moving to the next position, you will see newly selected text. This is the default content of a snippet tabstop (placeholder) and you may decide to either delete it (as you would normally delete selected text), or edit it with your content. After being satisfied with yout input, you can press TAB and you will be redirected to another tabstop, again with possible edit and so on. This is a very convenient way of working with snippets or code templates if you want.

If you are interested in more detailed explanation, please continue reading, otherwise skip to the next chapter. Following text is mainly for superusers and developers wishing to define custom snippets for themselves.