# Auto-completion and Templates

To select a template, complete a variable reference or a function call, press the `Tab` key after a character sequence. The suggestions shown depend on the current context. For example, to complete a variable reference, type $ followed by the first characters of the variable and press `Tab`. To enforce auto-complete and see all suggestions, press `Ctrl-Space` (or `Option-Space` on Firefox for Mac), which will also show a list of all available templates when activated on a new line or after whitespace.

If there's only one suggestion, it will be inserted immediately. Otherwise, a popup is shown. In the popup, use the cursor keys to choose a suggested code or function template. Press `Enter` to select the current template.

# Code Templates

eXide supports the same code templates as the textmate editor (a well-known editor on the Mac). To see all available code templates in a mode, place the cursor after whitespace and press `Ctrl-Space` (or `Option-Space`).

For example, to add a new function, enter "fun" and press `Tab`. Some templates also respect the current text selection: to transform a block of code into a "let" statement, select the block, call autocomplete and choose the "let" template.

### Adding Templates

New templates can be added by editing the `.snippets` files which can be found in the `eXide/templates` collection.

# Navigating within templates

Within a code or function template, press `Tab` to cycle between template parameters. Press `Escape` when you are done with the parameters and want to input an ordinary tab character.

# Browsing the code

eXide not only parses the code currently open in the editor, it also knows all imported modules. To directly jump to the definition of a function in an imported module, place the cursor somewhere in the name of the called function and press `F3`. If the function is in an imported XQuery module, eXide will open it in a new tab. Note: this only works for modules written in XQuery, which reside in the database, not Java modules.

To get help on a called function, press `F1` instead of F3 while the cursor is positioned within the function's name.

# Code Hints and Quick Fixes

eXide continuously validates your XQuery code. Errors show up with a red icon in the side bar, while code hints appear with a yellow warning sign. Moving the mouse over the icon displays a description. For some types of errors or warnings, a quick fix might be available if you click on the icon. Currently this includes the following errors/warnings:

- Unknown namespace
- Unknown function
- Namespace not used
- Unused import

# Refactoring

## Variables and Function Names

In XQuery mode, eXide can refactor local variables and function names. To start refactoring, place the cursor into the name of the function in a function declaration or the name of a variable. Select the Rename action from the XQuery menu. All occurrences of the function or variable will be added to the current editor selection. All selections will change synchronously as you type. To end the editing, press `ESC`.

## Extract New Function

To create a new function from a selected piece of code, choose the menu item Extract function from the XQuery menu. The selection must contain a complete code block. This code will be parsed and a new function is created from it with all required parameters declared.

# Browsing and importing modules

To open or import an XQuery module, press `F4` anywhere in the editor to see all modules available in the database. To insert an import statement for a module at the current cursor position, click on the `Import` button. eXide automatically determines the path to use for the import. Modules residing in the same application collection will be imported with a relative path.

Note: the `Import` button will only be shown if the active editor tab contains an XQuery document.