Templates
Prev | Chapter 3. Usage | Next

## Templates

Geany supports several templates for file headers, multiline comments (frame comments), function descriptions, a typical ChangeLog entry and a short GPL notice. To use these templates, just open the Edit menu or open the popup menu by right-clicking in the editor widget, and choose "Insert Comments" and insert templates as you want.

Some templates (like file header or ChangeLog entry) will always be inserted at the top of the file.

To insert a function description, the cursor must be inside of the function, so that the function name can be determined automatically. The description will be positioned correctly one line above the function, just check it out. If the cursor is not inside of a function or the function name cannot be determined, you cannot insert a function description.

Each template can be customized to your needs. The templates are in the configuration directory, which is in `~/.geany/` (see the section called “Command line options” for further information about the configuration directory). Just open the desired template with an editor (ideally Geany ;-) ) and edit the template as your needs. There are some wildcards which will be automatically replaced by Geany at startup.

All wildcards must be enclosed by "{" and "}", e.g. {date}.

In the configuration dialog you can find a tab "Templates" (see Figure 3.5, “Template tab in preferences dialog”). You can define the default values which will be inserted in the templates. You should restart Geany after making changes, because they are only read at startup.

Since Geany 0.3 there are also templates for creating new files. They can be found in `~/.geany/`, too. All template files for creating new files begin with `template.filetype.` followed by the filetype. At creating a new file with a filetype template, the template for the fileheader is automatically prepended. Please note that the complete behaviour is still under development and will probably be changed in one of the next releases. Sorry.

Table 3.8. Template wildcards

Wildcard | Description | Available in following templates
--- | --- | ---
developer | The name of the developer. | filetypes, file header, function description, ChangeLog entry
initial | The developer's initials, e.g. "ET" for Enrico Tröger or "JFD" for John Foobar Doe. | filetypes, file header, function description, ChangeLog entry
mail | The email address of the developer. | file header, function description, ChangeLog entry
company | The company the developer is working for. | filetypes, file header, function description, ChangeLog entry
year | The current year in the format: YYYY | filetypes, file header, function description, ChangeLog entry
version | The initial version of a new file. | filetypes, file header, function description, ChangeLog entry
date | The current date in the format: YYYY-MM-DD | filetypes, file header, function description, ChangeLog entry
untitled | The string "untitled" (this will be translated to your locale), used in filetype templates | filetypes, file header, function description, ChangeLog entry
geanyversion | The actual Geany version, e.g. "Geany 0.8" | filetypes, file header, function description, ChangeLog entry
datetime | The current date and time in the format: DD.MM.YYYY HH:mm:ss ZZZZ | file header, function description
filename | The filename of the current file. Only available for the file header template. | file header
gpl | This wildcard inserts a short GPL notice. | file header
functionname | The function name of the function at the cursor position. This wildcard will only be replaced in the function description template. | function description

If you need any other wildcards or a special date/time format, please email the author `<enrico.troeger@uvena.de>`.

Prev | Up | Next
Filetype definition files | Home | Appendix A. Scintilla keyboard commands