Abbreviations
Prev | Chapter 6. Editing Source Code | Next

## Abbreviations

Using abbreviations reduces the time spent typing long but commonly used strings. For example, in Java mode, the abbreviation “sout” is defined to expand to “System.out.println()”, so to insert “System.out.println()” in a Java buffer, you only need to type “sout” followed by `C+;`. An abbreviation can either be global, in which case it can be used in all edit modes, or specific to a single mode.

Abbreviations can be edited in the Abbreviations pane of the Utilities>Global Options dialog box; see the section called “The Abbreviations Pane”. The Java, VHDL. XML and XSL edit modes include some pre-defined abbreviations you might find useful. Other modes do not have any abbreviations defined by default.

Edit>Expand Abbreviation (keyboard shortcut: `C+;`) attempts to expand the abbreviation named by the word before the caret. If no expansion could be found, it will offer to define one.

Automatic abbreviation expansion can be enabled in the Abbreviations pane of the Utilities>Global Options dialog box. If enabled, pressing the space bar after entering an abbreviation will automatically expand it.

If automatic expansion is enabled, a space can be inserted without expanding the word before the caret by pressing `Control`-`E` `V` `Space`.

### Positional Parameters

Positional parameters are an advanced feature that make abbreviations much more useful. The best way to describe them is with an example.

Java mode defines an abbreviation “F” that is set to expand to the following:

    for(int $1 = 0; $1 < $2; $1++)

Expanding `F#j#array.length#` will insert the following text into the buffer:

    for(int j = 0; j < array.length; j++)

Expansions can contain up to nine positional parameters. Note that a trailing hash character (“#”) must be entered when expanding an abbreviation with parameters.

If you do not specify the correct number of positional parameters when expanding an abbreviation, any missing parameters will be blank in the expansion, and extra parameters will be ignored. A status bar message will be shown stating the required number of parameters.

Prev | Up | Next
Bracket Matching | Home | Folding