Using the Expressions editor

Last updated on Jun 5, 2024

Use the different options in the expression editor to customize your expressions.

You can customize the code editor interface of the expression editor, including highlighting JavaScript syntax with custom colors, line numbers, code folding, and auto-complete. To customize these options, select After Effects > Settings > Scripting & Expressions.

Scripting and Expressions dialog
Scripting & Expressions pane in the Preferences dialog box.

Expression editor code interface

Customize syntax highlighting of JavaScript syntax and After Effects methods and properties

Customize syntax highlighting
Customize syntax highlighting

  • You can assign custom colors to different types of syntax, the background, and the text selection, as well as adjust the alpha ( opacity ) of the text selection. Select the dropper icon to select a color from the color wheel.
  • You can customize how the expression editor looks based on the different themes available. Select the Theme drop-down list and select from the themes. You may also save custom themes.

Edit preferences

Edit preferences
Edit preferences

You can control how the expression snippets and the text editor look in the UI. Use these preferences to edit font size, syntax highlighting, adjust indents, and so on.

Code Preview box

Code Preview box
Code Preview box

All changes to the syntax colors and other editor preferences can be previewed live in this code preview box.

Tip

Use throw to debug expressions inline. This is useful when you want to see the code error within the expression editor field to save time and ensure efficient debugging.

Throw to debug expressions inline
Throw to debug expressions inline

Example 1: Display error in your code snippet

Open a comp in After Effects that has expression snippets.

In the Timeline panel, select a layer and use Alt+Click to display the expression in the Expression Editor field.

Expression Editor field
Expression Editor field

Select the editor field to enter the edit mode.

Click in the editor to enable editing in the Expression Editor
Click in the editor to enable editing in the Expression Editor

In this example, select MILE in the first line and change it to mile in lowercase. This triggers an error in the code, and After Effects displays an error message within the code snippet.

Error message displayed in the code snippet
Error message displayed in the code snippet

After Effects also displays an error banner with details about the line number where the error occurs.

Error banner
Error banner

Example 2: Auto-suggestions based on the commonly used components

In the same expression, change the layer name from mile to MILE.

As you type, After Effects displays a drop-down list with a set of suggestions that After Effects pulls from the layer names of the project.

Layer name auto-suggestions
Layer name auto-suggestions

Composition names, layer names, footage names, and effect names are all pulled into the autoComplete and shown in the correct context with their respective comp(), layer(), footage(), and effect() methods. This allows you to keep your expression active while referencing items in the project. You don't need to scroll the timeline or open other panels to refer to properties or items using the pick whip.

More Expression resources

Now that you have understood some of the concepts behind expressions, come to the community for some real-life examples, and to share your work.

The AE Enhancers forum also provides many examples and much information about expressions, as well as scripts and animation presets.