The syntax editor offers keyboard shortcuts and actions to assist in writing code.

Table 1. Syntax editor keyboard shortcuts and actions for writing code
Keyboard shortcut or action Description Example
Write code

Scripting assistance

Control+Spacebar

Displays a list of valid elements at the insertion point such as:
  • Class names
  • Function names
  • Object names
  • Variable names
Double-click an entry to add it to the script.
Note: The elements are based on server or client type of script. However, these elements are available based on the UI type you select. For example, spUtil is available for Service Portal client scripts and g_navigation is available for Desktop scripts.
A line of code for a variable definition with a pop-up window displaying potential scripting elements.
Enter a period character after a valid class name.

Displays a list methods for the class.

Double-click an entry to add it to the script.

A line of code for a variable definition with a pop-up window displaying potential scripting elements.
Enter an open parenthesis character after a valid class, function, or method name.

Displays the expected parameters for the class or method.

Enter the expected parameters as needed.

A line of code for a variable defining a method call. There is a pop-up window displaying potential scripting elements.

Toggle full screen mode

Control+M

Switches between displaying the form with the full screen and displaying it normally.
Format code
  • Windows: Control+Shift+B
  • Mac: Command+Shift+B
Formats the selected lines to improve readability. Several lines of unformatted codeSeveral lines of code formatted for readability
Toggle comment
  • Windows: Control+/
  • Mac: Command+/
Adds or removes the comment characters // from the selected lines. A line of code selected with no comment charactersA line of code selected with comment characters added to the front of the line.
Insert macro text
  1. In the Script field, type the macro keyword text. For example help.
  2. Press Tab.
Inserts macro text at the current position. A line of code containing the string help.The macro text for help added to the script.
Search
Start search
  • Windows: Control+F
  • Mac: Command+F

Highlights all occurrences of a search term in the script field and locates the first occurrence.

You can create regular expressions by enclosing the search terms between slash characters . For example, the search term /a{3}/ locates the string aaa .

A search field with the term gr.The search results of the search term gr displaying four highlighted items. The first search result is selected.
Find next
  • Windows: Control+G
  • Mac: Command+G
Locates the next occurrence of the current search term in the script field. Use Start Searching to change the current search term. The search results of the search term gr displaying four highlighted items. The second search result is selected.
Find previous
  • Windows: Control+Shift+G
  • Mac: Command+Shift+G
Locates the previous occurrence of the current search term in the script field. Use Start Searching to change the current search term. The search results of the search term gr displaying four highlighted items. The first search result is selected.
Replace
  • Windows: Control+E
  • Mac: Command+E
Replaces the next occurrence of a text string in the script field. A replace field with the string gr.A replace with field with the string gl.A replace confirmation dialog with options for Yes, No, and Stop
Replace all
  • Windows: Control+;
  • Mac: Command+;
Replaces all occurrences of a text string in the script field. A replace field with the search term gr.A replace with field with the string gl.
Help
Help
  • Windows: Control+H
  • Mac: Command+H
Displays the list of syntax editor keyboard shortcuts. A pop-up window displaying the keyboard shortcuts for the Syntax Editor.
Show description
  • Windows: Control+J
  • Mac: Command+J
Displays API documentation for the scripting element at the cursor's current location. A line of code selected with a pop-up window displaying API help for the GlideRecord object
Show macros
  1. In the Script field, type help.
  2. Press Tab.
Displays the list of available syntax editor macros as text within the script field. A line of code containing the string help.The macro text for help added to the script.