Workflow Tips

This section contains a list of features included in Charcoal Editor that are designed to improve the scripting workflow in Maya.

Single Line Execution

Using the Ctrl+Alt+Enter hotkey will execute the line of code at the current cursor position. This eliminates the need to select the text prior to execution.

Note: Leading whitespaces are stripped prior to execution to avoid Python indentation errors.

Execute and Execute All

Charcoal Editor provides the ability to excute the full script or a selected block of code. As with the native script editor, Ctrl+Enter executes the select text (or the entire script if nothing is selected) and Ctrl+Shift+Enter executes the entire script regardless of selection.

Note: Unlike Maya's script editor, code is never deleted from the editor when executed.

Print MEL Variables

Highlighting and executing a variable in MEL will print the current value of the variable to the Output Window. This is equivalent to using the MEL print command.

Note: Double-clicking on a MEL variable will highlight the variable name including the '$' character.

Highlight Matching Words

When a word is highlighted in the Code Editor, any matching words will be highlighted as well. This can used to quickly identify all instances of a word in the script. The color of the matching highlight can be changed in Preferences.

Note: This behavior also exists in the Output Window. Selecting a word in the Output Window will highlight any matching words.

Errors and Warnings

Syntax errors and warnings are displayed in left sidebar on the line where a problem was identified. If desired, the display of errors, warnings and info can be disabled in Preferences.

Info

Charcoal Editor recognizes "TODO" comments and will add a blue info icon to the left sidebar any time the text "TODO" is found in a comment.

Example:

# TODO: Replace hardcoded paths with constants

Auto-Completion

Auto-completion displays a list of suggested commands, methods and variables, based on the characters in the current word. By default, auto-complete is displayed when the user presses Ctrl+Space (MEL and Python) or inserts a '.' character (Python). If there are no suggestions, the auto-complete dialog will not be displayed. When the dialog is displayed can be modified in Preferences.

The Python auto-completer is an advanced parser that parses the current script and builds a list of classes, methods, variables and imports. Because of the dynamic nature of Python it is not always possible to determine the variable types. Additionally, syntax errors in the script can cause auto-completion to fail.

Note: A syntax error icon is displayed in the left sidebar, as a red circle with an '!' inside, on the line where an error is found.

Configurable Layout

Charcoal Editor provides a customizable layout with dockable widgets that can be torn-off or repositioned within the main window. The visibility of widgets, toolbars and the tab bar can be toggled through the main menu or preferences dialog. A tab can be reordered by dragging it left or right in the tab bar or moved to a different view by dragging it into that view.

Note: The Charcoal Editor layout is persistent and is maintained between Maya sessions.

Split-Screen Editing

By default, Charcoal Editor only displays one code view. When working with multiple files it can be beneficial to split the editor into two different views, each with their own tab bar, maintaining a different set of buffers.

To split the code view, or move a tab to the other view, right-click on the tab and select Move to Other View from the context menu. Additionally, tabs can be moved between views by dragging the tab into the new view.

When all tabs are removed from a split code view, the editor will be restored to a single code view.

Show Hidden Tabs and Spaces

Indentation in languages such as Python are very important. Mixing tabs and spaces in a script can result in difficult to identify errors.

Enabling Show Tabs and Spaces in the main main or toolbar will display symbols for tabs and spaces in the Code Editor. The symbols are unobtrusive and make it easy to identify spacing inconsistencies.

Convert Tabs to Spaces

Quickly unify the spacing in a script by converting all tabs to spaces. The Convert Tabs to Spaces option found under the Edit menu will replace all tabs in the scene with the appropriate number of spaces to maintain the current spacing.

Related Links