Code Editors

code_editor

Enterprise Architect provides a number of editors that you can use to maintain scripts, code and templates. Specifically, these are the:

Each editor has its own features, but they are all based on a common Code Editor control.

The Code Editor provides a variety of functions to assist with the code editing process, including:

A range of these functions is available through keyboard key combinations and/or context menu options; see the Code Editor Key Bindings and Code Editor Context Menu topics.

You can customize several of the Code Editor features by setting properties in the Code Editor configuration files. For example, by default the line containing the cursor is always highlighted, but you can turn the highlighting off. For more information see the Code Editor Configuration Guide located as a PDF file in the Config directory under your Enterprise Architect installation directory.

Syntax Highlighting

The Code Editor highlights - in colored text - the standard code syntax of most language file formats supported by Enterprise Architect, namely:

  • Ada (.ada, .ads, .adb)
  • ActionScript (.as)
  • BPEL Document (.bpel)
  • C++ (.h, .hh, .hpp, .c, .cpp, .cxx)
  • C# (.cs)
  • Delphi/Pascal (.pas)
  • Diff/Patch Files (.diff, .patch)
  • Document Type Definition (.dtd)
  • DOS Batch Files (.bat)
  • DOS Command Scripts (.cmd)
  • HTML (.html)
  • Interface Definition Language (.idl, .odl)
  • Java (.java)
  • Javascript (.javascript)
  • JScript (.js)
  • Modified Backus-Naur Form Grammar (.mbnf)
  • PHP (.php, .php4, .inc)
  • Python (.py)
  • Standard Generalized Markup Language (.sgml)
  • Structured Query Language (.sql)
  • SystemC (.sc)
  • Visual Basic 6 (.bas)
  • VB.NET (.vb)
  • VBScript (.vbs)
  • Verilog (.v)
  • VHSIC Hardware Description Language (.vhdl)
  • Visual Studio Resource Configuration (.rc)
  • eXtensible Markup Language (.xml)

Bookmarks

Bookmarks denote a line of interest in the document. You can toggle them on and off for a particular line by pressing [Ctrl]+[F2]. Additionally, you can press [F2] and [Shift]+[F2] to navigate to the next or previous bookmark in the document.

In the following diagram, a bookmark has been set on line 17.

bookmark

Cursor History

The Code Editor Control keeps a history of the previous 50 cursor positions. An entry in the history list is created when:

  • The cursor is moved more than 10 lines from its previous position
  • The cursor is moved in a find/replace operation.

You can navigate to an earlier point in the cursor history by pressing [Ctrl]+[-], and a to later point by pressing [Ctrl]+[Shift]+[-].

Brace/Bracket Matching

When you place the cursor over a brace or bracket, the Code Editor highlights its corresponding partner. You can then navigate to the matching brace by pressing [Ctrl]+[E].

braceMatch

Automatic Indentation

For each supported language, the Code Editor adjusts the indentation of a new line according to the presence of control statements or scope block tokens in the lines leading up to the cursor position.

For more information on customizing automatic indentation for a language, see the Configuration Guide.

Commenting Selections

For languages that support comments, the Code Editor can comment entire selections of code. The Code Editor recognizes two types of commenting:

  • Line Commenting - entire lines are commented from the start (for example, // This is a comment)
  • Stream Commenting - sections of a line are commented from a specified start point to a specified end point (for example, /* This is a comment */).

You can toggle comments on the current line or selection by pressing [Ctrl]+[Shift]+[C] for line comments, or [Ctrl]+[Shift]+[X] for stream comments.

lineCommentSelection

For more information on customizing selection commenting for each language, see the Configuration section.

Scope Guides

If the mouse is placed over an indentation marker, the Code Editor performs a 'look back' to find the line that started the scope at that indentation level. If the line is found and is currently on screen, it is highlighted in light blue.

scopeGuideOnScreen

Alternatively if the line is off screen, a calltip is displayed advising of the line number and contents.

scopeGuideOffScreen

Zooming

You can zoom into and out of the contents of the Code Editor using [Ctrl]+mousewheel or [Ctrl]+keypad[+] / [Ctrl]+keypad[-]. Zoom can be restored to 100% by using [Ctrl]+keypad[/].

Line Selection

If you want to move the cursor to a specific line of code, press [Ctrl]+[G] and, in response to the prompt, type in the line number. Press the OK button. The editor displays the specified line of code with the cursor at the left.