|Prev||Working with Plugins||Next|
The File Templates plugin allows you to create files based on other files.
When you first install Kate, you need to enable the plugin:
In the tree on the left of the screen, click Plugins.
In the Plugin Manager panel on the right, select File Templates, and then click .
You can now use any file as a template (this creates a copy of the file with an empty URL.) Special template files can contain macros to fill in information such as your name, email address, the current date, and position the cursor at a convenient position in the new file.
You can easily create a new template from an open document.
Templates that you save to the template folder are listed under the menu item → .
The template folder is part of the KDE file system, and consists of at least
KDEDIRS environment variable contains additional directories, those are
searched for a similar subdirectory as well. If equally named templates are
found, the one in the local (KDEHOME) folder is chosen.
Presents you with Open File dialog that allows
you to use any file as a template. If the chosen file has the
katetemplate it will be parsed
for template information and macros.
The remainder of submenus contains links to templates. Click a menuitem to create a file as described by the menu item text.
This will launch a dialog with a list of all templates found within the template directories, along with options to add, edit or remove templates.
When creating a file from a template that contain template macros, some macros appears as editable variables in the text. Such variables appears as underlined words in the text.
The first variable will be selected, so you just have to type to edit it. If the document text contains more instances of the same variable, they are changed as you edit. To move to the next editable variable, press the Tab key. When the last variable is edited, the list is dropped, and your Tab key works as normal.
To create a new template, use the → Item to launch the template management dialog. In that, click to launch the File Template Wizard. You will be asked for an optional file to turn into a template and prompted for template information settings, and a template file will be created for you.
Alternatively, you can create a template manually by
adding template information to the top of any file, add text and macros,
and save it with the
The template menu gets automatically updated if you chose to store your template in the template directory.
To edit a template, use the → . Select the template you want to work on and click , and the template file will be opened. Close the dialog, edit the template file as desired, save it and close it. Changes to templates takes immediate effect, you can activate the template to test your changes after saving it.
If you use files with the extension
katetemplate, they will be parsed for template
information, macros and a cursor position.
While reading in the file, the parser keeps
lines beginning with the phrase
katetemplate: and searches them for
template information in the form VARIABLENAME=VALUE. The first line not
katetemplate: will be taken as the
start of the template contents. VALUE may contain any character but
equal sign (=). Legal variable names are:
This is the template name, displayed in the → menu.
The group places the template in a submenu of the → menu.
This is the name that will be set for the
document, and displayed in the file list and title bar. If the
%N that will be replaced
with a number, increasing if more documents has the same
The plug-in will try to set the Highlight for the new document to the value of this variable. The value should be the name, as found in the → .
A short informative description of the template. This is currently used to set a Whatsthis string for the menu item, but may be used for more purposes in the future.
A string identifying the author, for example
in the form
Name <email address>.
This is currently used to set a Whatsthis string for the menu
item, but may be used for more purposes in the
While parsing the template contents, macros in the form
expanded. If you use the
$ prefix, the
expanded macro will be treated as a editable variable when a document
is created from the template, whereas if you use
% it is not, unless expanding failed.
The following macros are expanded:
Expands to the current time in your locale format.
Expands to the current date in short format.
Expands to the current date and time, formatted as a string according to your locale.
The current year as a four digit number.
The full name of the current month, according to your locale.
Expands to the current day of the month.
Expands to the 'hostname' of your computer.
Expands to 'i'.
Expands to your full name, as defined by the owner addressee in your standard KDE addressbook.
Expands to your first name, as defined in the owner addressee in your standard KDE addressbook.
Expands to your last name, as defined in the owner addressee in your standard KDE addressbook.
Expands to your email address, as defined by the owner address in your standard KDE addressbook.
Any macro not in the above list is treated as a editable variable no matter the prefix. If the same variable occurs multiple times in the template, they can be edited at once after creating a document from the template.
Kate Plugin “File Templates” copyright 2004 Anders Lund
Documentation copyright 2004 Anders Lund
|Python Pâté Plugins||Up||XML Validation|