The Script Editor¶
- A full-featured text search tool that can search in multiple files; see Searching in text.
When you position the cursor in a document and begin typing, the Toolkit offers completion choices from among keywords, global functions, functions that are defined in the current document, and functions defined in the object-model dictionary that is currently selected from the flyout menu.
You can use the flyout menu at the upper right corner of the document window to choose an object-model dictionary to use for completion. Available dictionaries depend on which applications are loaded. See Inspecting object models.
The Edit menu offers two kinds of brace-matching selection, that operate when the cursor is placed immediate after an opening brace character, or immediately before a closing brace:
- Edit > Select to Brace: Moves the cursor to the matching bracing, but does not select any text. The
default keyboard shortcut is
- Edit > Select Including Brace: Selects all text between the braces. The default keyboard shortcut is
SHIFT CTRL 0(zero).
Brace characters include parentheses, curly braces, and square brackets.
When Word Wrap is off, you can automatically indent or outdent entire blocks of text. To indent a block of
text, select some or all of the text on the line or lines, and press TAB. (Be careful; if Word Wrap is on, this
deletes the selected text.) To outdent, press
A special comment format is reserved for a code versioning statement, which is used internally by Adobe scripts, but is available to all scripters. Use Edit > Insert Version Tag to insert a comment containing the file name and current date-time, in this format:
/** * @@@BUILDINFO@@@ SnpCreateDialog.jsx !Version! Tue Dec 05 2006 08:03:38 GMT-0800 */
You are responsible for manually updating the !Version! portion with your own version information.
Undo and redo¶
Choose Undo or Redo from the Edit menu or from the document window’s right-click context menu to revoke and reinstate multiple editing changes sequentially. The change history is kept from when a file is created or loaded, and maintained through file-save operations.
Before running the new script or saving the text as a script file, use Edit > Check Syntax to check whether
- If the script is syntactically correct, the status line shows “No syntax errors.”
- If the Toolkit finds a syntax error, such as a missing quote, it highlights the affected text, plays a sound, and shows the error message in the status line so you can fix the error.
The Script Editor supports triple-quote syntax to allow strings to span several source code lines. When entering a very long string, you can:
Enter it all on one line:
var myString = "This very long string might wrap onto a second line visually, but you typed no CR character when entering it."
Enter on multiple lines, using a backslash () continuation character at the end of each line:
var myString = "This string spans \ two lines."
Use triple quotes around the entire string on multiple lines:
var myString = """This "quoted" word is inside the multiline string enclosed by triple quotes."""
The triple-quote option allows the string to contain embedded quotes.
Searching in text¶
The Toolkit offers a search utility through the Edit > Find and Replace command. This command brings up the Find and Replace panel. If the panel is not docked, you can hide it by pressing ESC.
The Find and Replace panel allows you to search through multiple documents for text that matches a specific search string or regular expression. You can choose to search in:
- The current document, or the current selection in the current document
- All open documents
- All scripts made public by the current target application
- Folders that you have defined as favorite locations; see The Scripts panel and favorite script locations.
The results of a search are listed in the Find Results tab; by default, this is stacked with the Find and Replace panel, but you can drag it to another stack, or display it as an independent floating panel.
Double-click a result line in the Find Results panel to jump directly to the document and line where the text was found.
Using regular-expression syntax¶
The Toolkit supports a limited set of Regular Expression syntax for the Find and Replace dialog:
||Matches any character|
||Marks the start of a region for capturing a match.|
||Marks the end of a capturing region.|
||Matches the start of a word using the editor’s current definition of words.|
||Matches the end of a word using the editor’s current definition of words.|
||Escapes a character x that would otherwise have a special meaning. For example, [ is interpreted as a left bracket, rather than the start of a character set.|
||A set of characters; for example, [abc] means any of the characters a, b or c. You can also use ranges, for example [a-z] for any lower case character.|
||The complement of the characters in a set. For example, [^A-Za-z] means any character except an alphabetic character.|
||Matches the start of a line (unless used inside a set).|
||Matches the end of a line.|
||Matches 0 or more times. For example, Sa*m matches Sm, Sam, Saam, Saaam etc.|
In a replace operation, you can use the captured regions of a match in the replacement expression by
using the placeholders
\1 refers to the first captured region,
\2 to the second, and so
For example, if the search string is
Fred\([1-9]\)XXX and the replace string is
Sam\1YYY, when applied to
Fred2XXX the search generates
The style of highlighting is configurable, using the Fonts and Colors page of the Preferences dialog.