WinEdt Macro Library  | macro previous macro  | next macro


If you only need this macro because it is required by another package that you want to install, you can skip the following explanations, and continue with "Installation".


addOrUpdate — add, update or delete custom entries in existing macro files


This macro inserts, updates or deletes tagged code fragments in any sort of macro but makes especially sense in shortcut macros and of course also in GDI settings. For the moment, the macro checks the tags "@BEGIN" , "@END" and "@DATE" (all uppercase !) or resp. "$Begin: ??? $" , "$End: ??? $" and "$Date: ??? $" (all capitalized ; see example below).

The macro is able to insert new code fragments before the "// @DEFAULT" tag resp. End; command or to update an existing section if it is newer then the existing one ( "@DATE" has to be in ISO format: YYYY-MM-DD ).

This behavior is essential, because a setup routine has to respect customizations made by other mode contributors (who perhaps used this macro in their setup routines too). Simply copying new versions over existing ones is not a solution!


Suppose you have a macro file (eg. completeWord.edt invoked by a shortcut) that looks like this:

  CMD("Complete Word");

You want to insert a custom macro fragment, that should only react in a specific mode, in this example "XML" . Two tag syntax forms are allowed. The first one is inspired by JavaDoc:

  // @BEGIN: XML
  // @DATE: 2003-02-06
  // @AUTHOR: Georges Schmitz
  // -------------------------------------------------------------
  // -------------------------------------------------------------
  // @END: XML

The second form resembles RCS/CVS tags:

  // $Begin: XML $
  // $Date: 2003/03/20 10:00:04 $
  // $Author: schmitz $
  // -------------------------------------------------------------
  // -------------------------------------------------------------
  // $End: XML $

You do not know

  1. if this fragment already exists in completeWord.edt or
  2. if your setup macro comes with the newest version of the fragment
  3. and you don't want to edit the shortcut macro by hand (well, the running setup wouldn't be a setup anymore)

Incorporating the following instructions into your setup will do the job.

      Assign('extensionKey', 'XML');
      Assign('extensionFile', 'extensions\tagCompletion.edt');
      Assign('localTargetFile', '%b\Menus\Tools\completeWord.edt');
      Assign('globalTargetFile', '%B\Menus\Tools\completeWord.edt');

Used Local Variables

A key like XML that is used in the "@BEGIN" and "@END" tags. extensionKey is not released at the end of the macro, because in mode setup routines, you will probably execute this macro more than once with the same extensionKey value.
If set to 1, instruct the macro to delete the specific extension (helpful in uninstall routines). In this case, the following parameter extensionFile needs not to be specified.
The path to the file with the specific extension
the path to the global copy of the macro (%B ), eg. %B\Menus\Tools\completeWord.edt . A setup writer normally doesn't know, if WinEdt is running with a specific user profile at all, (located in %b ), so he can specify both locations.
the path to the local copy of the macro (%b ), where your fragment should be inserted, eg. %b\Menus\Tools\completeWord.edt (if localTargetFile doesn't exist, globalTargetFile is automatically copied to localTargetFile !).
presume that the content of this global variable can be found in the file (start backward searching at the end of file). If not defined, then End; or // @DEFAULT is used as default
can be used to demand a specific mininmal version of addOrUpdate.edt (ISO date format)

if the target file doesn't exist, use this flag (value=1) to force the generation of an empty one


see previous flag: this comment is inserted at the beginning of the generated file, eg. something like:

    Assign("targetFileGenerationComment","//Generated by XML Setup on %!7");


Put the macro in %b\Macros\macro\.



Macro contributed by Georges Schmitz <>

Revision and extensions by Robert <>

WinEdt Macro Library  | macro previous macro  | next macro