Working with Code Snippets

This topic explains how to use code snippets in dbForge Studio for MySQL.

Code snippets help to boost SQL code typing. You can use predefined snippets provided in the application and create your own to insert them in SQL scripts and queries.

dbForge Studio code snippets are XML files with the .snippet file name extension.

The Code Snippets window contains a rich collection of templates organized in folders. In this window, you can arrange and preview snippets. To view a snippet, select it in the window. If the preview pane is not visible, right-click a snippet and select Toggle preview on the menu.

Inserting Code Snippets

  1. Click Code Snippets on the View menu. The Code Snippets window opens.
  2. In the Code Snippets window, choose the required template and drag it to the SQL editor.
  3. Specify variable names and parameter values in the lines marked green, and the press ENTER to complete code fragment editing.

Alternatively

  1. Click Insert Snippet on the SQL Editor shortcut menu.
  2. Select the required template.
  3. Use the UP ARROW and DOWN ARROW keys to select the item in the snippets list.
  4. Specify variable names and parameter values in the lines marked green and press ENTER to complete code fragment editing.

Code snippets can also be inserted by entering template shortcut word or words and pressing the TAB key.

Note

If you want to include a code fragment into the inserted template, select it with the mouse pointer before placing snippet to the editor. If the snippet does not provide surrounding, selected text will be deleted.

To move the snippet to the root folder of the Code Snippets window, drag it on the one that already is in the root folder or to the upper border of the Code Snippets window.

Creating Code Snippets

  1. Click Snippets Manager on the Tools menu. The Snippets Manager window opens.
  2. Click New Snippet on the manager toolbar.

    Note

    Actual document look may slightly vary from the above image, depending on the product you use.

  3. In the Text field, enter the text of the snippet.
  4. Specify a shortcut and snippet description in the corresponding Shortcut and Description fields.

    Note

    The Location field is read-only and is filled automatically when you choose the folder available in the list of snippets.

    The shortcut (if any) will be taken as snippet name. If there is no shortcut specified, the new snippet will be named Snippet. To change the snippet name, double click it in the list of snippets and enter the needed name.

  5. Click Save on the toolbar.

Editing Code Snippets

  1. Click Snippets Manager on the Tools menu. The Snippets Manager window opens.
  2. Select the required snippet from the list of available snippets.

    Note

    Actual document look may slightly vary from the above image, depending on the product you use.

  3. Modify the snippet description, shortcut, and text in the corresponding fields.
  4. Click the Save button on the manager toolbar.
  5. To change the snippet name, double click it in the list of available snippets.

Default Snippets Location

By default, all snippets are stored in a folder that is located at C:\ProgramData\Devart\dbForge Studio for MySQL\Snippets.

You can change the default location when editing an existing snippet or creating a new one by setting a new path in the Location field of Snippets Manager.