Categories


Popular topics



Scripting in UltraEdit is based upon JavaScript that has been extended with several properties and methods unique to UltraEdit / UEStudio. The scripting engine supports the core functionality of JavaScript 1.7. Further information on JavaScript may be found at the Mozilla developer site.

For information on the workflow of creating and adding scripts in UltraEdit / UEStudio, please see the Create and edit scripts topic. This topic is an exhaustive reference of the properties and methods that are unique and specific to UltraEdit / UEStudio and enable much of the scripting functionality within the editor.

Example script

The following script, when played in UltraEdit or UEStudio, will prompt the user for a value and update the active file that many times with that number of new lines.

var u = UltraEdit.getValue("Approximately how many lines to add to the file?",1);
var i = 0;

UltraEdit.activeDocument.bottom();
UltraEdit.activeDocument.write("\r\n");

while (i < u) {
  j = i + 1;
  k = j + 1;
  UltraEdit.activeDocument.write("This is update " + i + " to the file.\r\n");
  UltraEdit.activeDocument.write("This is update " + j + " to the file.\r\n");
  UltraEdit.activeDocument.write("This is update " + k + " to the file.\r\n");
  UltraEdit.save(); 
  i = k + 1;
}

Demo scripts are available in the UltraEdit / UEStudio installation directory in the "scripts" subdirectory. The UltraEdit site also contains several scripting tutorials as well as many user-submitted scripts.

Scripting techniques

Including scripts in scripts

You can include an external script in a script by reference as shown below:

// include externalScript.js

or

// include C:\full path\to external\script\externalScript.js

The include command must be preceded by a line comment. If you want to exclude an included script for debugging purposes, the include should be preceded by a doubled line comment, i.e.:

// // include externalScript.js

Keep in mind that scripts are executed as soon as the inclusion is processed, and inclusions are processed prior to the active script. If an include is inserted into the middle of a script file, it will actually execute prior to the script in which it is included. When building complex scripts in a modular fashion from smaller scripts, the best practice is to create a master script file that calls the included scripts, i.e.:

// include script1.js
// include script2.js
// include script3.js

Debugging scripts with var_dump()

The var_dump() function is a special feature to scripting in UltraEdit / UEStudio that works only with objects unique to UltraEdit / UEStudio. Running var_dump() on an object will output structured information about the object's members including type and value. Arrays and objects are explored recursively with values indented to show structure. Example:

var_dump(UltraEdit.frInFiles);

Default variable values

There are several variable values that are initialized by default every time a script starts in UltraEdit / UEStudio:

  • Column mode is always off.
  • Hex mode is always off.
  • Insert mode is always on.
  • The regular expression engine is always set to Perl.

These items are set every time a script runs but can be toggled via the associated scripting commands.

Special variables for clipboard contents and selection

Both ^s and ^c can be used with many script commands, and at runtime UltraEdit / UEStudio will replace this with the currently selected text or clipboard contents, respectively.

Properties / methods - application object

For both UltraEdit and UEStudio, UltraEdit is the application object that contains all scripting operations unique to the editor. The following commands act on the editor itself rather than the active document. Unless other parameters are noted, all application object commands must be invoked using the following format:

UltraEdit.commandName();

The table below shows all available application object commands.

Command Parameters Description
activeDocumentIdx This is a read-only property. Returns index of active document in the document array. Example:
var adI = UltraEdit.activeDocumentIdx;
clearClipboard Clears active clipboard
clipboardContent Text in quotes ("") if used to set clipboard content. Returns content of active clipboard. Example:
var clip = UltraEdit.clipboardContent;

May also be used to set the content of the active clipboard. Example:

UltraEdit.clipboardContent = "Hello World!";
clipboardIdx This is a read-only property. Returns index of active clipboard. Example:
var clip = UltraEdit.clipboardIdx;
closeFile()
  1. File path
  2. Save Mode
    • "0" - prompt to save
    • "1" - save and close
    • "2" - close without save
Closes active file. Example:
UltraEdit.closeFile("C:\\temp\\test.txt",2);

To close the active file without saving or prompt, regardless of path:

UltraEdit.closeFile(UltraEdit.activeDocument.path,2);

Note: Any backslash used in parameters must be escaped as shown above (i.e. \\ rather than \).

columnMode This is a read-only property. Returns Boolean value indicating if column mode is active. Example:
var columnActive = UltraEdit.columnMode;
columnModeOff() Turn column mode off. Example:
UltraEdit.columnModeOff();

Note: The column mode state prior to script execution will be restored once the script has completed processing.

columnModeOn() Turn column mode on. Example:
UltraEdit.columnModeOn();
decryptFilePrompt() Opens "Decrypt file" dialog and awaits user input. Example:
UltraEdit.decryptFilePrompt();
encryptFilePrompt() Opens "Encrypt file" dialog and awaits user input. Example:
UltraEdit.encryptFilePrompt();
frInFiles (object)
  • .directoryStart (string) full path of directory where search should begin
  • .encoding (int) numeric code page value to be used for search
  • .filesToSearch (int)
    • 0 - Files Listed
    • 1 - Open Files
    • 2 - Favorite Files
    • 3 - Project Files
    • 4 - Solution Files
  • .ignoreHiddenSubs (Boolean)
  • .matchCase (Boolean)
  • .matchWord (Boolean)
  • .openMatchingFiles (Boolean)
  • .regExp (Boolean)
  • .searchSubs (Boolean)
  • .unicodeSearch (Boolean)
  • .useEncoding (Boolean)
  • .searchInFilesTypes (string) files / types to search in
  • .find("string to find");
  • .replace("string to find", "string to replace");


Only used with replace:

  • .logChanges (Boolean)
  • .preserveCase (Boolean)

Only used with find:

  • .displayLinesDoNotMatch (Boolean)
  • .reverseSearch (Boolean)
  • .useOutputWindow (Boolean)
Searches through specified files to find the string in quotes "" based on the parameters specified. In general, you should set the parameters in the order shown to the left before calling the find() or replace() method.


Find in Files example:

UltraEdit.frInFiles.directoryStart = "c:\\temp\\";
UltraEdit.frInFiles.searchInFilesTypes = "*.txt";
UltraEdit.frInFiles.useOutputWindow = true;
UltraEdit.frInFiles.find("Some String");

Replace in Files example:

UltraEdit.frInFiles.directoryStart = "c:\\temp\\";
UltraEdit.frInFiles.searchInFilesTypes = "*.txt";
UltraEdit.frInFiles.useOutputWindow = true;
UltraEdit.frInFiles.replace("Some String", "A New String");
getString()
  1. String in quotes ("") used as text in the prompt dialog
  2. Optional flag (int):
    • 0 - string entered is inserted into active file
    • 1 - string entered is not inserted but saved as variable value
Prompts for string to insert at current location. The "prompt" is the prompt or question that is displayed to the user when the script is run. Examples:
UltraEdit.getString("What is your name?");

or:

var name = UltraEdit.getString("What is your name?",1);
getValue()
  1. String in quotes ("") used as text in the prompt dialog
  2. Optional flag (int):
    • 0 - numeric value entered is inserted into active file
    • 1 - numeric value entered is not inserted but saved as variable value
Prompts for a numeric value to insert at current location. The "prompt" is the prompt or question that is displayed to the user when the script is run. Examples:
UltraEdit.getValue("How old are you?");

or:

var age = UltraEdit.getValue("How old are you?",1);
insertMode() Change text editing mode to insert mode.
insOvrMode This is a read-only property. Returns Boolean value indicating if insert mode is on. Example:
var insertActive = UltraEdit.insOvrMode;
messageBox()
  1. Message text in quotes ("")
  2. (Optional) Title text in quotes ("")
Opens message dialog with "OK" button. Example:
UltraEdit.messageBox("You're about to run a script!", "Script notification");
newFile() Creates an empty, new file.
open()

File name in quotes ("")

Open the specified file. The file name must be in quotes. Either ^s or ^c can be used in the file name parameter, and UltraEdit / UEStudio will replace this with the currently selected text or clipboard contents, respectively. Once the file is open, it becomes the active file. Examples:
UltraEdit.open("c:\\temp\\test.txt");

or:

UltraEdit.open("^c");

or:

UltraEdit.open("c:\\temp\\^c");

or:

UltraEdit.open("FTP::myserver.com\\/www|index.html");
overStrikeMode() Change text editing mode to overstrike mode for characters typed.
perlReOn() Switch regular expression syntax for find / replace to Perl style regular expressions.
regexMode This is a read-only property. Returns an integer indicating active regular expression type.
  • 0 = UltraEdit legacy
  • 1 = Unix style
  • 2 = Perl style

Example:

var regexType = UltraEdit.regexMode;
runTool() String in quotes ("") specifying the case sensitive menu name of tool to run. Runs a tool. The tool must be configured from Configure tools under the User tools dropdown in the Advanced tab. Example:
UltraEdit.runTool("Run SAS code");
save() Save active file.
saveAll() Save all active files.
saveAs() File name in quotes ("") Save the active file as the filename specified. The filename must be in quotes. Either ^s or ^c can be used in the file name parameter, and UltraEdit / UEStudio will replace this with the currently selected text or clipboard contents, respectively.
UltraEdit.saveAs("c:\\temp\\test.txt");

or:

UltraEdit.saveAs("^s");

or:

UltraEdit.saveAs("^c");
selectClipboard() Clipboard number (0-9) Select the specified clipboard (0 = Windows clipboard and 1-9 specifies user clipboards.) Example:
UltraEdit.selectClipboard(2); // switch to user clipboard #2
ueReOn() Switch regular expression syntax for find / replace to UltraEdit legacy style regular expressions.
unixReOn() Switch regular expression syntax for find / replace to Unix style regular expressions.


Properties / methods - document object

For both UltraEdit and UEStudio, document[] is a JavaScript array object which is a child of the UltraEdit application object. document[] is an array containing all open files, and each item in the document[] array is a separate document object which can be acted upon via the properties and methods documented in the below table. You can access specific documents by index based on file tab order (e.g., document[0], ... document[8]).

For both UltraEdit and UEStudio, activeDocument is a JavaScript object which is a property of the UltraEdit application object. activeDocument always refers to the currently active file.

For example:

UltraEdit.activeDocument.write("test");

would write the word "test" to the active file, while the following:

UltraEdit.document[4].write("test");

would write the word "test" to to the fifth file (based on file tab order) currently open.

Unless other parameters are noted, all document object commands must be invoked using the following format:

UltraEdit.activeDocument.commandName();

or:

UltraEdit.document[i].commandName();

The table below shows all available document object commands.

Command Parameters Description
ansiToOem() Convert file from ANSI to OEM. Example:
UltraEdit.activeDocument.ansiToOem();
ASCIIToUnicode() Convert file from ASCII to Unicode (UTF-16)
ASCIIToUTF8() Convert file from ASCII to UTF-8
bottom() Move caret to very last position in file
cancelSelect() Clears any selection in active file. Example:
UltraEdit.activeDocument.cancelSelect();
clearAllBookmarks() Clears all bookmarks in active file. Example:
UltraEdit.activeDocument.clearAllBookmarks();
codePage This is a property of the active / specified document Returns value of code page for active file. Example:
var cp = UltraEdit.activeDocument.codePage;

May be used to set code page to be used for active file. Example:

UltraEdit.open("C:\\temp\\korean_file.txt")
UltraEdit.activeDocument.codePage = 949;
collapseAll() Collapse all foldable text in active file. Example:
UltraEdit.activeDocument.collapseAll();
columnCenterJustify() Center justify selected columns
columnCut() Numeric value of columns to cut Cut in column mode the selected columns or the specified number of columns from current cursor position to bottom of the file. Value "0" must be used to cut the selected columns.
columnDelete() Numeric value of columns to delete Delete in column mode the selected columns or the specified number of columns from current cursor position to bottom of the file. Value "0" must be used to delete the selected columns.
columnInsert()
  1. Starting number (int)
  2. Increment (int)
  3. Leading Zero (Boolean)
  4. Hex (Boolean)
Insert number in selected columns. If there is no selection the insertion will run from the cursor location to the last line of the file. Example:
UltraEdit.activeDocument.columnInsertNum(2, 3 , false, true);
columnLeftJustify() Left justify selected columns
columnRightJustify() Right justify selected columns
commentAdd() Insert the line comment string as defined in the syntax highlighting language used to highlight the current file at start of every selected line or the current line if there is no selection. This command has no affect on a file not highlighted with a syntax highlighting language or when the language has no line comment definition. The cursor position does not change and the selection remains.
commentRemove() Remove the line comment string as defined in the syntax highlighting language used to highlight the current file at start of every selected line or the current line if there is no selection. This command has no affect on a file not highlighted with a syntax highlighting language or when the language has no line comment definition. The line comment string must be at start of the line (column 1) without preceding whitespace. A line comment string after one or more spaces or tabs is ignored and not removed. The cursor position does not change and the selection remains.
CommentSelectionAdd() Insert the "block comment on" string at start and the "block comment off" string at end of a selection as defined in the syntax highlighting language used to highlight the current file. If nothing is selected on execution of the command, both strings are inserted at current cursor position. This command has no affect on a file not highlighted with a syntax highlighting language or when the language has no block comment definition. If the selected block contains already a block comment and the language does not support nested blocks comments, command CommentAdd is automatically executed instead of this command for inserting the line comment string at start of every selected line if the language supports a line comment. The cursor moves to start of the inserted "block comment on" string and the selection is removed after execution when the block comment strings are inserted.
CommentSelectionRemove() Remove the "block comment on" string at start and the "block comment off" string at end of a selection as defined in the syntax highlighting language used to highlight the current file. The command has no affect if nothing is selected on execution of the command. And the command works only if the current selection starts with the "block comment on" string and ends with the "block comment off" string. Whitespace inside the selection before "block comment on" string or after "block comment off" string are not ignored and result in not removing the block comment strings. The cursor moves to start of the selection and the selection is removed after execution when the block comment strings are removed.
copy() Copy selected text to the clipboard. If there is no selection, the line at the current cursor location will be copied if Enable copy/append of current line when no selection is active is configured in Settings » Editor » Miscellaneous.
copyAllBookmarkLines() Copy all bookmarked lines in active file to clipboard
copyAppend() Copy selected text and append it to the clipboard. If there is no selection, the line at the current cursor location will be copied if Enable copy/append of current line when no selection is active is configured in Settings » Editor » Miscellaneous.
copyFilePath() Copy the active file path/name to the clipboard
currentChar This is a read-only property of the active / specified document. Returns value of character at cursor. Example:
var char = UltraEdit.activeDocument.currentChar;
currentColumnNum This is a read-only property of the active / specified document. Returns value of current column number. The first column is numbered as "1". Example:
var col = UltraEdit.activeDocument.currentColumnNum;
currentLineNum This is a read-only property of the active / specified document. Returns value of current line number. Example:
var lineNum = UltraEdit.activeDocument.currentLineNum;
currentPos This is a read-only property of the active / specified document. Returns value of current position in bytes from the beginning of the file. Example:
var pos = UltraEdit.activeDocument.currentPos;
cut() Cut the selected text from the file to the clipboard. If there is no selection, the line at the current cursor location will be cut if Enable copy/append of current line when no selection is active is configured in Settings » Editor » Miscellaneous.
cutAllBookmarkLines() Cut all bookmarked lines in active file to clipboard
cutAllBookmarkLines() Cut all bookmarked lines in active file to clipboard
cutAppend() Cut the selected text from the file and append it to the clipboard. If there is no selection, the line at the current cursor location will be cut if Enable copy/append of current line when no selection is active is configured in Settings » Editor » Miscellaneous.
decodeBase64() Convert selected text from Base64. Example:
UltraEdit.activeDocument.decodeBase64();
delAllBookmarkLines() Delete currently bookmarked lines in active document. Example:
UltraEdit.activeDocument.delAllBookmarkLines();
delAllHiddenLines() Delete lines currently hidden/folded in active document. Example:
UltraEdit.activeDocument.delAllHiddenLines();
deleteText() Delete current character or selected text
deleteLine() Delete the active line
deleteToEndOfLine() Delete from the current caret position to the end of the line
deleteToStartOfLine() Delete from the current caret position to the start of the line
deleteToStartOfLine() Delete from the current caret position to the start of the line
dosToMac() Convert all line terminators in file to Mac (legacy) format
dosToUnix() Convert all line terminators in file to Unix format
dupeLine() Inserts duplicate of active line below cursor
encodeBase64() Convert selected text to Base64. Example:
UltraEdit.activeDocument.encodeBase64();
encoding This is a read-only property of the active / specified document. Returns value of encoding for active document. Example:
var enc = UltraEdit.activeDocument.encoding;
endSelect() Stop selecting text (see startSelect for details)
expandAll() Expands all folded text in active file. Example:
UltraEdit.activeDocument.expandAll();
fileSize This is a read-only property of the active / specified document. Returns size of referenced file in bytes. Example:
var size = UltraEdit.activeDocument.fileSize;
findReplace (object)
  • matchCase (Boolean)
  • .matchWord (Boolean)
  • .mode (int)
    • 0 - Current File
    • 1 - In Selection
    • 2 - All Open Files
  • .regExp (Boolean)
  • .searchAscii (Boolean)
  • .searchDown (Boolean)
  • .searchInColumn (Boolean)
  • .fromCol (int) default: 0
  • .toCol(int) default: -1
  • .find("string to find");
  • .replace("string to find", "string to replace");


Only used with replace:

  • .preserveCase (Boolean)
  • .replaceAll (Boolean)
  • .replaceInAllOpen (Boolean) - supersedes .mode in replace:
  • .selectText (Boolean) - replaces only in selected text
Find the string in quotes "" based on the parameters specified. In general, you should set the parameters in the order shown to the left before calling the find() or replace() method. Example:
UltraEdit.activeDocument.findReplace.matchWord = true;
UltraEdit.activeDocument.findReplace.find("someWord");

or:

UltraEdit.document[0].findReplace.matchWord = true;
UltraEdit.document[0].findReplace.matchCase = true;
UltraEdit.document[0].findReplace.replace("Copper", "Silver");

Note: all properties once set are active for all following finds and replaces until the property is set again to a different value.

fromEBCDIC() Convert file to ANSI from EBCDIC format
gotoBookmark() Index of bookmark to jump to or -1 to go to next bookmark Jump to the next/specified bookmark. The indexes start with 0. If a user enters an index that is greater than the actual number of bookmarks then caret is automatically set to the next bookmark like when using -1 as bookmark number. Example:
UltraEdit.activeDocument.gotoBookmark(0);
gotoBookmarkSelect() Index of bookmark to select to, or -1 to select to next bookmark Select all text from the current caret position to the next/specified bookmark. The indexes start with 0. If you specify an index that is greater than the actual number of bookmarks then caret is automatically set to the next bookmark like when using -1 as bookmark number. Example:
UltraEdit.activeDocument.gotoBookmarkSelect(0);
gotoEndOfNextWord() Jump to end of next word. Example:
UltraEdit.activeDocument.gotoEndOfNextWord();
gotoEndOfNextWordSelect() Select all text from current caret position to end of next (immediate right) word. Example:
UltraEdit.activeDocument.gotoEndOfNextWordSelect();
gotoEndOfPrevWord() Jump to end of previous word. Example:
UltraEdit.activeDocument.gotoEndOfPrevWord();
gotoEndOfPrevWordSelect() Select all text from current caret position to end of previous (immediate left) word. Example:
UltraEdit.activeDocument.gotoEndOfPrevWordSelect();
gotoLine() Numeric value of line and column number to jump to Jump to the specified line and column number. Use line number 0 to jump to a specific column in the current line. Example:
UltraEdit.activeDocument.gotoLine(1,5);
gotoLineSelect() Numeric value of line and column number to jump to Select from current caret position to specified line / column number. Use line number 0 to jump to a specific column in the current line while selecting text. Example:
UltraEdit.activeDocument.gotoLineSelect(1,5);
gotoPage() Numeric value of page to jump to Jump to specified page number. Example:
UltraEdit.activeDocument.gotoPage(5);
gotoPageSelect() Numeric value of page to select to Select from current caret position to specified page number. Example:
UltraEdit.activeDocument.gotoPageSelect(5);
gotoPos() Numeric value specifying position in number of chars from beginning of file Jump to specified position (passed as parameter in number of chars from beginning of file)
gotoPosSelect() Numeric value specifying position in number of chars from beginning of file Select to specified position (passed as parameter in number of chars from beginning of file). If the position exists prior to the current position in the file, the selection will be made backwards from the current position.
hexDelete() Numeric value specifying number of bytes to delete Delete the specified number of bytes at the current position from the file
hexInsert() Numeric value specifying number of bytes to insert Insert the specified number of bytes (spaces/hex 20) into the file at the current position
hexMode This is a read-only property of the active / specified document. Returns a Boolean value indicating if hex mode is active. Example:
var hexActive = UltraEdit.activeDocument.hexMode;
hexOff() Turn hex mode off - switch to regular text editing mode
hexOn() Turn hex mode on
hideOrShowLines() Hide the selected lines, or if active line is folded, expand it
insertLine() Inserts blank line below current caret position
insertPageBreak() Insert a form feed/page break character at the current caret position in the file
insertTemplate()
  • Name of template group in quotes followed by a dot, e.g. ("glo.") (optional)
  • Name of template in quotes, e.g. ("templateName")
  • Index of global template (legacy)
Insert the specified template into the file. Insert global templates by specifying the template name with or without a template group name. Example:
UltraEdit.activeDocument.insertTemplate("userTime");

If desired, you can specify global ("glo" or "global"), Layout ("env" or "environment", formerly Environment), Language ("lng" or "language") and Project ("prj" or "project") groups as well as template names. Examples:

UltraEdit.activeDocument.insertTemplate("glo.userTime");
UltraEdit.activeDocument.insertTemplate("global.userTime");
UltraEdit.activeDocument.insertTemplate("env.Power1");
UltraEdit.activeDocument.insertTemplate("environment.Power1");
UltraEdit.activeDocument.insertTemplate("lng.class");
UltraEdit.activeDocument.insertTemplate("language.class");
UltraEdit.activeDocument.insertTemplate("prj.noDesc");
UltraEdit.activeDocument.insertTemplate("project.noDesc");

If preferred, you can specify global templates based on its index in the template list. Example:

// Inserts first template in template list
UltraEdit.activeDocument.insertTemplate(0);
invertCase() Invert the case of selected text
isChar() "char" This checks if the current character at the caret position is the character specified in the parmeter. Example:
if (UltraEdit.document[1].isChar('k')) {
 //do these commands...
} else {
 //do these commands...
}
isCharGt() "char" This checks if the current character at the caret position is greater than the specified character. Example:
if (UltraEdit.document[1].isCharGt('k')) {
 //do these commands...
} else {
 //do these commands...
}
isColNum() number This checks if the current character at the caret position is the specified column number. Example:
if (UltraEdit.activeDocument.isColNum(13)) {
 //do these commands...
} else {
 //do these commands...
}
isColNumGt() number This checks if the current character at the caret position is greater than the specified column number. Example:
if (UltraEdit.activeDocument.isColNumGt(13)) {
 //do these commands...
} else {
 //do these commands...
}
isEof() number This checks if the current caret position is at the end of the file. Example:
if (UltraEdit.document[1].isEof()) {
 //do these commands...
} else {
 //do these commands...
}
isExt() "string" This checks if the file extension of the active file matches the specified string. Example:
if (UltraEdit.document[1].isExt("txt")) {
 //do these commands...
} else {
 //do these commands...
}
isFound() This checks the results from the last find command in the script and will conditionally execute further commands based on the result. Example:
UltraEdit.activeDocument.findReplace.find("string");
if (UltraEdit.activeDocument.isFound()) {
 //do these commands...
} else {
 //do these commands...
}
isFTP() This checks if the current file is a file loaded via FTP/SFTP and not a local/network file.
if (UltraEdit.document[1].isFTP()) {
 //do these commands...
} else {
 //do these commands...
}
isHexModeOn() This checks if the active file is currently in hex mode.
if (UltraEdit.activeDocument.isHexModeOn()) {
 //do these commands...
} else {
 //do these commands...
}
isName() "string" This checks if the active file name (not path or extension) matches the specified string. Example:
if (UltraEdit.document[1].isName("foo")) {
 //do these commands...
} else {
 //do these commands...
}
isNotFound() This checks the results from the last find command in the script and will conditionally execute further commands based on the result. Example:
UltraEdit.activeDocument.findReplace.find("string");
if (UltraEdit.activeDocument.isNotFound()) {
 //do these commands...
} else {
 //do these commands...
}
isReadOnly() This checks if the file is read-only. Example:
if (UltraEdit.activeDocument.isReadOnly()) {
 //do these commands...
} else {
 //do these commands...
}
isSel() This checks if there is any selection in the file. Example:
if (UltraEdit.document[1].isSel()) {
 //do these commands...
} else {
 //do these commands...
}
isWordWrap() This checks the word wrap toggle state in the file and returns true if it's enabled. Example:
if (UltraEdit.activeDocument.isWordWrap()) {
 //do these commands...
} else {
 //do these commands...
}
key()
  • "BACKSPACE"
  • "DEL"
  • "DOWN ARROW"
  • "END"
  • "HOME"
  • "LEFT ARROW"
  • "PGDN"
  • "PGUP"
  • "RIGHT ARROW"
  • "UP ARROW"
  • "CTRL+END"
  • "CTRL+HOME"
  • "CTRL+LEFT ARROW"
  • "CTRL+RIGHT ARROW"
Issue a keyboard command into the file via the script. Generally used for navigation in the file and for backspace or delete. The "CTRL+" modifier may be used as with normal editing to modify the command. For inserting arbitrary text, use the "write" command instead. Examples:
UltraEdit.activeDocument.key("BACKSPACE");
UltraEdit.activeDocument.key("CTRL+RIGHT ARROW");
length This is a read-only property of the active / specified document. Returns number of open files. Example:
var num_of_files = UltraEdit.document.length;
lineTerminator This is a read-only property of the active / specified document. Returns a numeric value indicating line terminator type in active document. Example:
var lt = UltraEdit.activeDocument.lineTerminator;

Possible return values:

  • -2 = Mac (legacy), but content of file contains currently DOS line terminators
  • -1 = Unix, but content of file contains currently DOS line terminators
  • 0 = DOS
  • 1 = Unix
  • 2 = Mac (legacy)
matchBrace() Find next brace matching pair (from position of caret forward) and select the text between them.
moveLineDown() Move current line down one line in active document. Example:
UltraEdit.activeDocument.moveLineDown();
moveLineUp() Move current line up one line in active document.
oemToAnsi() Convert file from OEM to ANSI.
paste() Paste the contents of the active clipboard into the file.
path This is a read-only property of the active / specified document. Returns full path of specified file. Example:
var path = UltraEdit.activeDocument.path;
previousBookmark() Jump to the previous bookmark
previousBookmarkSelect() Select from current caret position to the previous bookmark
readOnlyOff() Toggles read-only off for file / makes it writable
readOnlyOn() Makes file read-only
reIndentSelection() Re-indents selected text. Example:
UltraEdit.activeDocument.reIndentSelection();
returnToWrap() Convert hard returns to word wrap in selected text.
selectAll() Select all text in the file
selection This is a read-only property of the active / specified document. Returns currently selected text. Example:
var selected_text = UltraEdit.activeDocument.selection;
selectLine() Select all text on active line including line terminator (if it exists). The caret is positioned at the beginning of the next line.
selectToBottom() Select all text from the current caret position to the end of file.
selectToTop() Select all text from the current caret position to the top of file.
selectWord() Select the current word (same as double clicking a word).
setActive() Sets specified file in the document[] array as the active file / tab. Example:
UltraEdit.document[1].setActive();
sort (object)
  • .ascending (Boolean)
  • .col1Start (int) start column key 1
  • .col1End (int) end column key 1
  • .col2Start (int) start column key 2
  • .col2End (int) end column key 2
  • .col3Start (int) start column key 3
  • .col3End (int) end column key 3
  • .col4Start (int) start column key 4
  • .col4End (int) end column key 4
  • .ignoreCase (Boolean)
  • .removeDuplicates (int)
    • 0 - disable
    • 1 - ...where all keys match
    • 2 - ...where any keys match
  • .remKey1 (Boolean)
  • .remKey2 (Boolean)
  • .remKey3 (Boolean)
  • .remKey4 (Boolean)
  • .type int
    • 0 - character order
    • 1 - numeric sort
    • 2 - use locale
  • sort() - actually runs the sort
Sort the file, or selected text according to specified parameters. Set the parameters first before executing the sort() command. Example:
UltraEdit.activeDocument.sort.ascending = true;
UltraEdit.activeDocument.sort.ignoreCase = false;
UltraEdit.activeDocument.sort.removeDuplicates = 1;
UltraEdit.activeDocument.sort.remKey1 = true;
UltraEdit.activeDocument.sort.remKey2 = true;
UltraEdit.activeDocument.sort.type = 0;
UltraEdit.activeDocument.sort.col1Start = 1;
UltraEdit.activeDocument.sort.col1End = 15;
UltraEdit.activeDocument.sort.col2Start = 35;
UltraEdit.activeDocument.sort.col2End = 50;
// Now run the sort with the above parameters
UltraEdit.activeDocument.sort.sort();
sortAsc()

sortDes()

  1. Sort type:
    • 0 - Sort based on character order
    • 1 - Sort based on numeric value, not character order
    • 2 - Make sort locale specific
  2. Ignore Case (Boolean)
  3. Remove duplicates (Boolean)
  4. Sort Keys (int) Up to four pairs of start/end keys may be specified, all separated by commas
Sort the file, or selected text in ascending or descending order. Examples:
// Sort ascending
UltraEdit.activeDocument.sortAsc(0, true, true, 1, -1);
// Sort descending
UltraEdit.activeDocument.sortDes(1, true, false, 4, 8);
spacesToTabs() Convert (leading) spaces within the file to tabs
spacesToTabsAll() Convert all spaces within the file to tabs
startSelect() Start selection. This turns the selection mode on. Any caret movement or positioning will be with selection on and the text is selected. endSelect will stop the selection mode. The selected text will remain selected until another command causes it not to be selected as with normal editing.
tabsToSpaces() Convert all tabs in the file to spaces
timeDate() Insert the time and date into the file at the current location
toCaps() Capitalize each word in the selected text
toEBCDIC() Convert file to EBCDIC format
toggleBookmark() Set or remove a bookmark at the current line
toLower() Convert the selected text to lower case
top() Move caret to very first position in file
toUpper() Convert the selected text to upper case
trimLeadingSpaces() Trim leading spaces from each line of current file
trimTrailingSpaces() Trim trailing spaces from each line of current file
unicodeToASCII() Convert file from Unicode to ASCII
unixMacToDos() Convert all Unix and Mac line terminators in the file to DOS format
UTF8ToASCII() Convert file from UTF-8 to ASCII
wordWrapOff() Turns off word wrap in file
wordWrapOn() Turns on word wrap in file
wrapToReturn() Column number at which wrap is performed. Enter 0 to insert returns at the window boundary Convert selection from word wrap to hard returns. Example:
// Insert returns at column 60
UltraEdit.activeDocument.wrapToReturn(60);
write() Text to write in quotes ("") Write specified text at cursor location. Example:
UltraEdit.activeDocument.write("This is a test.");

or:

// Write clipboard contents
UltraEdit.activeDocument.write("^c");
xmlConvertToCRLF() Converts single-line XML text to indented XML format

Properties / methods - output window object

For both UltraEdit and UEStudio, outputWindow is a JavaScript child object of the UltraEdit application object.Unless other parameters are noted, all output window object commands must be invoked using the following format:

UltraEdit.outputWindow.commandName();

The table below shows all available output window object commands.

Command Parameters Description
clear() Clears contents of output window. Example:
UltraEdit.outputWindow.clear();
copy() Copies contents of output window to active clipboard. Example:
UltraEdit.outputWindow.copy();
showOutput (property) Boolean Determines visibility of data that is written to the output window via script. Currently that includes outputWindow.write() and var_dump(). Example:
// Disable this script from writing to output window
UltraEdit.outputWindow.showOutput = false;
showStatus (property) Boolean Determines visibility of all status information in output window (script name, success/failure of script, and errror information). Example:
UltraEdit.outputWindow.showStatus = true;
showWindow() Boolean Toggles visibility of output window. Example:
UltraEdit.outputWindow.showWindow(true);
visible This is a read-only property. Returns a BOOLEAN value indicating if output window is visible. Example:
// Show the output window if it's not visible
if (!UltraEdit.outputWindow.visible) {
  UltraEdit.outputWindow.showWindow(true);
}
write() Text to write in quotes ("") Write specified text to output window. This will only support one line at a time and may not include line terminators. Example:
UltraEdit.outputWindow.write("Line 1.\r\nLine 2.");
MediaWiki spam blocked by CleanTalk.