The name of the global template
file is
UETMPLTE.TPL in directory
%APPDATA%\IDMComp\UltraEdit\Templates or the templates directory configured at
Advanced - Settings or Configuration - Directories. It is not possible to create a global template
file with name
NewBat. But the macro works if you have created a global template with name
NewBat stored in file
UETMPLTE.TPL using
Modify Templates dialog. This dialog can be opened with:
- right clicking into Template List view and left clicking on context menu item Modify templates (any user interface mode);
- in toolbar/menu mode with traditional menus with clicking in menu Advanced on menu item Display/modify templates...;
- in toolbar/menu mode with contemporary menus with clicking in menu Coding in submenu Code template on menu item Modify code templates;
- in ribbon mode with clicking on ribbon tab Coding in last ribbon group Tools on second item Code template.
In ribbon mode and in toolbar/menu mode with contemporary menus it is not possible to open the
Modify Templates dialog with active file not being syntax highlighted on using UltraEdit for Windows v25.20.0.88 or UEStudio v18.20.0.18. This is a bug in my point of view because of this dialog is not only used for creating/editing syntax language templates. So it should be always possible to click on
Modify code templates. I have reported this issue to IDM support by email.
It must be made sure after opening
Modify Templates that template group
Global is selected in drop-down list at top right edge of the window to create/edit global templates.
My suggestions:
You could add a second global template with name
GetFileName with content
[FILE_NAME] and use as macro:
Code: Select all
InsertMode
ColumnModeOff
NewFile
Template NewBat
SaveAs ""
PerlReOn
Find MatchCase RegExp Up "rem \K(?=\.bat)"
Template GetFileName
Key UP ARROW
Key UP ARROW
This macro creates the new file with the lines stored in global template
NewBat, opens the
Save As dialog and inserts the name of the saved batch file in line with
rem .bat without file path and without file extension before moving caret to end of first remark line.
But perhaps better would be a global template with name
GetFileNameExt with content
[FILE_NAME][FILE_EXTENSION] and following code for the macro file:
Code: Select all
InsertMode
ColumnModeOff
NewFile
"@set echoonoff=off
@echo %echoonoff%
rem
rem
rem
rem
Exit /b
"
SaveAs ""
GotoLine 5 5
Template GetFileNameExt
GotoLine 3 5
It inserts the lines for a new batch file always directly from macro code. So it makes use of only one global template with name
GetFileNameExt to insert name of just saved batch file without path. Even this global template could be omitted by replacing the macro command
Template GetFileNameExt by:
Code: Select all
Clipboard 9
CopyFilePath
Paste
ClearClipboard
Clipboard 0
GotoLine 5 5
PerlReOn
Find MatchCase RegExp ".+\x5C"
Replace ""
The disadvantage of this solution to get name of just saved batch file without path written into the batch file is that it produces one additional undo record because of inserting the name of the batch file first with full path and next deleting file path.
Another solution would be using for global template
NewBat the content:
Code: Select all
@set echoonoff=off
@echo %echoonoff%
rem ^
rem
rem [FILE_NAME][FILE_EXTENSION]
rem
Exit /b
And use for the macro:
Code: Select all
InsertMode
ColumnModeOff
NewFile
SaveAs ""
Template NewBat
This solution would produce only one undo record which would remove everything inserted by template
NewBat.
All of my suggestions were tested by me with UE v25.20.0.88 before posting them here.