
There are programmers who use tools like
UltraEdit32 .
In no case do not advertise this product, just decided to share information about some of its features.
This article describes the possibilities for writing scripts for UltraEdit v.14.
To automate routine tasks, UltraEdit has two tools:
- Macros - used to record sequences of calls to menu functions, button presses and other actions performed for their subsequent repetition.
Created are created in the automatic recording mode of the macro, when each action is taken into account.
They are recorded in the form of Basic - like language in the form of sequences of actions.
- Scripts - designed to create more flexible automation scripts that are difficult to implement using macros.
They are created in the same text editor, ordinary programming.
They are written in the form of JavaScript (v.1.7.) Scripts, which is good news.
So, first a few general provisions, and then a few examples that I constantly use myself.
Scripting

Creating scripts is very simple, in the “
Scripting ” menu there is a tab “
Scripts ... ” with which you can easily and simply manage all the available scripts. Also, when you select “
Script list ”, a window with a list of scripts becomes available, which can be attached in a convenient place, for example, as in the second figure, in the lower left corner.

')
More details on the script management tools can be found on the
website , but not in Russian.
Scripts are stored in regular .js files and are connected automatically when the program starts.
It should be understood that scripts are not sets of functions, and when you call, everyone works from beginning to end.
To use the specific properties of the document, another one has been added to the standard JavaScript objects:
UltraEdit , which is the main interface to the current workspace.
The main useful properties and methods of the UltraEdit object
- activeDocument - oddly enough, provides access to the current active document.
Example :
UltraEdit.activeDocument.write( 'Hello Habr' );
Will add the text 'Hello Habr' to the position of the current cursor.
- activeDocument.selection - provides access to the current selected text.
Example :
var str = UltraEdit.activeDocument.selection;
str = str.replace(/Word/g, "Habr" );
UltraEdit.outputWindow.showWindow( true );
UltraEdit.outputWindow.write(str);
Replaces all words in Word with Habr in the selected text and displays the result in the information output window.
- activeDocument.selection.copy () / cut () / paste () - I think it needs no special comments.
- activeDocument.key () - allows you to simulate keystrokes during the execution of the script.
Example :
UltraEdit.activeDocument.key( "HOME" );
UltraEdit.activeDocument.startSelect();
UltraEdit.activeDocument.key( "END" );
UltraEdit.messageBox(UltraEdit.activeDocument.selection);
Select the entire current line and show it in the alert.
- messageBox - method, replacing the usual alert ().
- Array document [] - in contrast to the activeDocument provides the ability to refer to any of the currently open tabs on the index.
Example :
UltraEdit. document [1].write( 'Hello second tab' );
Adds the text 'Hello second tab' to the cursor position in the text on the second tab.
Note, document.length respectively contains the number of open tabs.
- getString is a method for entering information into a script.
Example:
var str = UltraEdit.getString( " " ,1);
Displays the text input box and places the result in the str variable.
- outputWindow - Another interesting object that allows you to work not with a text, but with an additional information output window, designed to display current information and logs.
Example :
UltraEdit.outputWindow.showWindow( true );
UltraEdit.outputWindow.write( "Test outputWindow" );
Opens the output window if it is not shown and displays the text: 'Test outputWindow '.
- newFile - a method that creates a new, empty tab.
Example :
UltraEdit.newFile();
We considered the most interesting properties and methods.
A full description of all the methods is in the help of the program, as well as on the site you can find some good examples of scripts.
And now a few simple scripts that I prefer to always keep on hand
Replace all double quotes in selected text with single quotes:UltraEdit.activeDocument.mode = 1; // ,
UltraEdit.activeDocument.findReplace.selectText = true ;
UltraEdit.activeDocument.findReplace.replaceAll = true ;
UltraEdit.activeDocument.findReplace.replace( "\"" , "'" );
Commenting selected text:UltraEdit.activeDocument.cut();
UltraEdit.activeDocument.write( "/*" );
UltraEdit.activeDocument.paste();
UltraEdit.activeDocument.write( "*/" );
I did it through the clipboard, because it's easier, but you need to remember that it overwrites the current buffer.
As an antonym to the previous script, uncommenting the selected text:UltraEdit.activeDocument.mode = 1; // ,
UltraEdit.activeDocument.findReplace.selectText = true ;
UltraEdit.activeDocument.findReplace.replaceAll = true ;
UltraEdit.activeDocument.findReplace.replace( "/*" , "" );
UltraEdit.activeDocument.findReplace.replace( "*/" , "" );
* Source code was highlighted with Source Code Highlighter .
There are certainly more opportunities, but I use these scripts most often.
Pavel Osipov
06/17/2009.