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

WildcardDescriptionAvailable in following templates
developerThe name of the developer.filetypes, file header, function description, ChangeLog entry
initialThe developer's initials, e.g. "ET" for Enrico Tröger or "JFD" for John Foobar Doe.filetypes, file header, function description, ChangeLog entry
mailThe email address of the developer.file header, function description, ChangeLog entry
companyThe company the developer is working for.filetypes, file header, function description, ChangeLog entry
yearThe current year in the format: YYYYfiletypes, file header, function description, ChangeLog entry
versionThe initial version of a new file.filetypes, file header, function description, ChangeLog entry
dateThe current date in the format: YYYY-MM-DDfiletypes, file header, function description, ChangeLog entry
untitledThe string "untitled" (this will be translated to your locale), used in filetype templatesfiletypes, file header, function description, ChangeLog entry
geanyversionThe actual Geany version, e.g. "Geany 0.8"filetypes, file header, function description, ChangeLog entry
datetimeThe current date and time in the format: DD.MM.YYYY HH:mm:ss ZZZZfile header, function description
filenameThe filename of the current file. Only available for the file header template.file header
gplThis wildcard inserts a short GPL notice.file header
functionnameThe 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 .