Snippets (Part 1)

If you ever find yourself repeately typing the same bits of text over and over again (and let’s face it programmers… some days that’s all it feels like, am I right?) then you will appreciate the functionality that snippets will provide. Snippets are essentially bits of text that are automatically inserted into an editing buffer when a keyword is entered in the editing buffer (the keyword is erased and replaced with the associated text). Using snippets to enter code will save you lots of time and typing and will also generate text that is free of errors.

Though there are several applications that exist to handle snippets in a general fashion, TKE has snippet support that has more functionality for programmers as well as better control over what snippets are active depending on the programming language being used in the current editing buffer. In this and the following articles, we will explore TKE snippets in much greater detail so that you can take full advantage of their functionality.

Types of Snippets

Snippet support in TKE comes in a few different flavors. They are as follows:

  1. General and language-specific text snippets
    • These are text snippets that can be accessed from any editing buffer, either regardless of language or for a specific language.
    • These are expanded when the snippet keyword is entered, followed by a whitespace character (i.e., tab, space, return)
    • Insert text, date/time, selected text, file information and clipboard data; set tabstops; mirror entered text; perform text transformations; execute shell scripts
    • Snippet syntax is written in a manner similar to TextMate snippets.
  2. Emmet HTML/XML snippets
    • Text snippets that are available by all editing buffers that are not set to the CSS language.
    • Expanded when the Control-E keyboard shortcut is used
    • Uses the Emmet HTML/XML abbreviation syntax (http://emmet.io)
  3. Emmet CSS snippets
    • Text snippets that are available by all editing buffers that are set to the CSS language.
    • Expanded when the Control-E keyboard shortcut is used
    • Uses the Emmet CSS abbreviation syntax
    • Available in the upcoming 2.4 stable release

We’ll take a look at each in detail in the upcoming weeks so stay tuned.

To see more information and download your copy of the TKE code editor, visit http://tke.sourceforge.net

Advertisements
Snippets (Part 1)