|
insertTemplateDescriptionInserts a template file and keeps indentation relative to actual cursor position The macro inserts a template file and preserves the indentation of the template text relative to the actual cursor position. WinEdt's Insert macros are not able to handle indentations in the desired way in case former lines were already indented. The solution pursued in this macro was to:
This macro is of special usefulness when working with strongly structured text (formatted through indentation). Lets take a look at a concrete example. You have for instance a template file like <varlistentry> <term></term> <listitem> <para></para> </listitem> </varlistentry> and want to insert it at the following place (XXXXXX): <variablelist> <varlistentry> <term>flag_safeInsert</term> <listitem> <para> wether the macro <function>safeInsert</function> is to be active </para> </listitem> </varlistentry> XXXXXX </variablelist> Doing this job with the simple Ins(); macro or via the Insert | Insert File... menu will result in messed up indentation: <variablelist> <varlistentry> <term>flag_safeInsert</term> <listitem> <para> wether the macro <function>safeInsert</function> is to be active </para> </listitem> </varlistentry> <varlistentry> <term></term> <listitem> <para></para> </listitem> </varlistentry> </variablelist> The macro insertTemplate instead produces nicely indented inserts: <variablelist> <varlistentry> <term>flag_safeInsert</term> <listitem> <para> wether the macro <function>safeInsert</function> is to be active </para> </listitem> </varlistentry> <varlistentry> <term></term> <listitem> <para></para> </listitem> </varlistentry> </variablelist> InstallationThe macro expects the local variable %$('insFilename'); to hold a valid path to a template file. You may deploy the macro in the following way: Mark(0); Assign('insFilename','%B\contrib\docbk\templates\varlistentry.dbk'); Exe('%B\macros\text\insertTemplate.edt'); Goto(0); CMD('Next Bullet'); DownloadMacro contributed by Georges Schmitz <georges.schmitz
|