[TOC] [Prev] [Next] [Bottom]



Chapter Five

Using Snippets


Snippets Basics and Operations

Snippets are named pieces of text, such as meta tags, HTML tags, standard headers and footers, plain text, JavaScript, and SQL. Snippets are a good way of saving text, HTML markup, or other commands that you use frequently. You can insert snippets into most text fields throughout Tango Editor.

Tango Editor comes with a large defined set of snippets and also lets you create your own snippets.

This chapter discusses how to:

  • use snippets
  • create new snippets.
[top] [back to top]


About Snippets

Snippets are used to quickly access text, meta tags, and HTML that you use often. You use snippets by dragging them into an editing window or double clicking on a snippet when you have an HTML editing window open.

A special feature of snippets lets you surround a selection of text with tags or meta tags, in addition to putting text, tags, or meta tags at a particular place.

Your snippets are saved as text files within the My Snippets folder inside the Windows/your_login folder (under Windows 95) or inside the WinNT/Profiles/your_login folder (under Windows NT). You can edit Tango snippet files with a text editor or HTML editor, or edit them within the Snippets workspace.

The Snippets Workspace

You manipulate and manage snippets in the Snippets Workspace.

To display the Snippets Workspace

Open the Workspace window by choosing Workspace from the View menu and click the Snippets tab.

You expand a folder by clicking the "+" sign to view its contents. Folders and snippets appear alphabetically.

Snippets are grouped in five folders:

For more information, see "Column Snippets"..

  • Builder Snippets contains pre-installed snippets used by the Search and New Record builders. These may be edited to change default HTML used in various places in the builders.
  • Column Snippets contains context-sensitive column snippets, used in the Search action, the Search Builder, and the New Record Builder.

For more information, see "Shortcuts to Configuration Variable Assignments: Snippets".

For more information on configuration variables, see the Meta Tags and Configuration Variables manual.

  • Configuration Variables contains pre-installed snippets of the Tango configuration variables. They are organized by category and by variable scope.
  • My Snippets contains snippets you create and edit.
  • Standard Snippets contains pre-installed snippets, which are not editable.

Context-Sensitive Menus in the Snippets Workspace

You can access a variety of commands when you right click items in the Snippets Workspace. There are two different context sensitive menus: one for folders, and one for snippets. In both menus, the Workspace commands--Allow Docking and Hide--are always active.

  • When you right click a snippet folder, a context-sensitive menu appears.

    If you are clicking on the My Snippets folder, you can create a new folder or new snippet, or show the properties of the My Snippets folder; the Delete and Rename commands are inactive.

    If you are clicking on a folder within the My Snippets folder, you can create a new folder or new snippet from this menu, delete an existing folder, rename it, or show its properties.

    If you are clicking on a non-editable folder, you can only show its properties.

  • When you right click a snippet, a different context-sensitive menu appears.

    The Copy command copies the content of a snippet to the Windows clipboard. When you have a window open where you can insert a snippet (for example, an HTML editing window), the Insert command is active.

    If you are clicking on a non-editable snippet, you cannot delete, edit, or rename the snippet, but you can copy its content to the clipboard or or show its properties.

    If you are clicking on an editable snippet (within the My Snippets folder), you can edit, copy, insert, delete, and rename snippets, as well as show their properties.

[top] [back to top]


Working With Snippets

Inserting Snippets

To insert a snippet into an application file

Do one of the following:

  • Drag the snippet to the desired text field (for example, the Results editing window).
  • Place your cursor where you want the snippet inserted and double click the snippet (HTML editing windows only).
  • Right click on the snippet and choose Insert from the context sensitive menu that appears.

!Tip: The content of a snippet appears as a Windows tool tip if you place your mouse cursor over the snippet.


You can select and drag several snippets at the same time.

To drag multiple snippets
  1. Select the snippets you want to drag by doing either of the following:
    • Clicking a snippet, holding down the Shift key, and clicking to select all the items in a list.
    • Clicking a snippet, holding down the Ctrl key, and selecting additional snippets (discontiguous selection).
  2. Drag the snippets into the desired text field.

    You can also double click and have the multiple snippets inserted at the insertion point, or right click on the snippets you have selected and choose Insert from the context sensitive menu that appears.

Creating Snippets

To create a snippet with existing text

Drag text to a folder in the Snippets workspace.

A snippet is created containing the text you dragged. The name of the new snippet defaults to "Untitled" and is editable. Type in a new name.

To create a snippet with new text
  1. Do either of the following:
    • From the Edit menu, click Snippet, then click New from the submenu.
    • Right click in the My Snippets folder of the Snippets Workspace and select New Snippet from the context-sensitive menu that appears.

    The New Snippet window appears.

  2. Fill in the window as follows.

    Name. Enter the name you are assigning to the new snippet.

    Create in this folder. The My Snippets folder and any subfolders are shown by default. Select where you want to create the new snippet.

  3. Click OK when you have given the new snippet a name and location.

    The Snippet contents window appears.

  4. Type in the content of your snippet or drag in text from elsewhere.

Using Placeholders in Snippets

When you right click the Snippet contents window, the Insert Placeholder command is listed in the context-sensitive menu that appears, in addition to the standard Tango editing commands.

Insert Placeholder inserts a special symbol--the yen symbol, ¥--into the Snippet contents window. This placeholder character allows you to create snippets that put HTML or meta tags around text you select before inserting the snippet. For example, you can create a snippet of the following text:

<H1>¥</H1>

To use this snippet while editing HTML, you would select the text you want to apply the <H1> format to, and then drag the snippet into the editing window or double click the snippet. The selected text is surrounded by the <H1> and </H1> tags.

Editing Snippets

To edit the contents of a snippet
  1. Right click the snippet you want to edit and choose Edit from the context-sensitive menu that appears.

    The Snippet content window appears.

  2. Edit the text.

    You can edit multiple snippets. Choosing Edit from the right click menu opens the contents window for all the selected snippets.

Creating a Snippets Folder

You can create new folders for holding your snippets in the My Snippets folder. This feature is useful if you want to categorize your snippets by type (for example, meta tags, SQL, HTML, and text snippets).

To create a new folder in the My Snippets folder
  1. Right click the My Snippets folder, and choose New Folder from the context sensitive menu that appears.

    A folder called Untitled appears. The name is already selected so you can change it.

  2. Type in a different name.

Renaming Snippets and Snippet Folders

To change the name of a snippet or snippet folder

Do one of the following:

  • Click a snippet or snippet folder and click again.
  • Right click the snippet or snippet folder, and choose Rename from the context-sensitive menu that appears.

The name of the snippet or snippet folder becomes editable; type in the new name.


!Note: Snippet names must be unique inside a folder.


Copying, Moving, and Deleting Snippets

To copy a snippet to the My Snippets folder for editing

Drag the snippet from the Standard Snippets, Configuration Variables or Column Snippets folders to the My Snippets folder.

You can move snippets to a different folder within the My Snippets folder by dragging snippets to their new location.

To duplicate a snippet within the My Snippets folder

Hold down the Ctrl key, and drag the snippet.

To delete a snippet or snippet folder

Click the snippet or snippet folder, and do one of the following:

  • Right click the snippet or snippet folder, and choose Delete from the context-sensitive menu that appears.
  • On the main toolbar, click the Delete icon.

  • From the Edit menu, choose Delete.
  • Press the Delete key.

A dialog box asking you if you want to delete the snippet appears. Click OK.


!Note: You can delete items from only the My Snippets and Builder Snippets folders.


You can delete multiple snippets. Choosing Delete from the right click menu deletes the selected snippets.

Snippet Properties

To see the properties of a snippet or snippet folder

Select the snippet or snippet folder, and do one of the following

  • From the View menu, choose Properties.
  • Type Alt-Enter.
  • Right click the snippet or snippet folder and choose Properties from the context-sensitive menu that appears.

The Snippet Properties or Snippet Folder Properties dialog box appears:

These dialog boxes list the name and location of the snippet or snippet folder, and the size of the snippet.

Column Snippets

The Column Snippets area of the Snippets workspace becomes active when the following are displayed:

  • Results HTML of the Search action.

The Search action's Select columns appear (and the Snippets tab is switched to and the Columns Snippets folder expanded, if necessary). (The Search action appears in the actions generated by the New Record Builder and Search Builder, as well as a separate action.)

  • New Record Response HTML in the New Record Builder.

Shows all the columns from the table being inserted into.

For more information, "<@COLUMN>" in the Meta Tags and Configuration Variables manual.

The content of each snippet is <@COLUMN name>, where the column name is the name from the Search action or New Record Builder you are editing.



[TOC] [Prev] [Next] [Bottom]



docs@pervasive.com

Copyright © 1998, Pervasive Software Inc. All rights reserved.