Feature Overview: Text Editor
PLCnext Engineer provides a powerful text editor for developing textual code and data type declarations.
This topic contains the following sections:
- Overview on the text editor features
- Default text editor settings
- Split view
- Expanded / collapsed editors area
- Pin/unpin particular editors
Overview on the text editor features
- Common features as known from standard ASCII editors, such as copying, pasting, cutting, moving of text, undo, redo, etc.
- Continuous automatic compiler checks in the background.While editing, the compiler continuously checks the syntax. Any detected errors are underlined red in the code/data type worksheet. When moving the mouse cursor on a red-underlined code, a tooltip shows information on the detected error (as shown in the following example). Additionally, errors are listed in the message window and indicated in the status bar.
- Insertion of ST code constructs, such as selection or iteration statements, as prepared code templates via context menu. Having inserted such a template, you simply have to overwrite the placeholders by the real values and names.
- Variable declaration via context menu.After entering a variable into the code which is not yet declared, the related declaration can be done via context menu command. The appropriate declaration is then inserted into the variables table.
When declaring an External variable, the related 'Global' declaration is automatically inserted into the Data List of the 'IEC 61131-3' node provided that the respective POU is already instantiated in the controller (i.e., a program instance exists or an FB instance within a program instance).
Depending on the POU type (program, function, FB) different variable types can be declared. Refer to the topic "Inserting Variables in ST". - Intellisense function.The Intellisense function simplifies entering code elements such as identifiers, keywords, variables, functions, function blocks, etc. in the code. Names to be inserted can be completed automatically by a special selection box.
- Syntax highlighting for ST statements, keywords, function/FB names. Examples: keywords are displayed blue, comments are green.
- Highlighting of selected text.Selecting a text in the editor marks all occurrences of this text in the currently opened editor.
- Expanding and collapsing code blocks.The editor provides syntax-based folding by enabling you to collapse and expand particular or all code blocks. To collapse a specific code block, click the '-' icon in the text editor, to expand an element, click ('+'). To collapse or expand all code blocks in the ST code worksheet, click the corresponding toolbar button.
- Delimiter highlightingThe pairs of delimiters: (...) parenthesis, [...] brackets, and {...} curly brackets are automatically highlighted.
- Region blocks (region/endregion pragmas)You can use the {region} pragma to specify a block of code lines that can be expanded or collapsed (see the following example). The region can have a name. The {region} block must be terminated by a {endregion} pragma.Syntax: {region 'regionname'} ... {endregion}Supported region formats:{region}
{region 'Text'}
{region "Text"}
{region('Text')}
{region("Text")} Example: - Caret positionThe position (line, column) of the active caret of the editor is shown in the status bar (right corner).
- Block selectionThe block selection allows to select a rectangular block of content in the editor instead of the whole line. The selection includes all of the characters captured within the rectangle defined by the start and end position in the selection.To select a block, press <ALT>+<SHIFT>, and then use the arrow keys. Alternatively, press <ALT>, and then press and move the left mouse button. You can then copy, paste, cut, or delete the entire selection. When a block is selected, and you type a text, the text will be entered in all lines of the selected text block at the same time.To exit the block selection mode, press <ESC>, or left-click anywhere in the worksheet.
- Find and replace functionThe 'GLOBAL FIND AND REPLACE' control available in the Cross Function Area can be used to search for certain strings and replace them by another string in all editors.
-
ZoomingThe zoom factor of the text can be changed using the zoom options in the lower right corner in the status bar.
Zooming in or out of the text in the text editor is also possible by just holding down the <Ctrl> key and using the wheel on your mouse to zoom in or out.
- EN/ENO (optional conditional execution of functions and function blocks) can be used in ST. EN/ENO is not supported in safety-related code.Refer to the help topic "Execution Control: EN/ENO" for details.
- In the variables subeditor at the lower border of the code editor, you can edit properties (except the name) of the variable at the cursor position or marked in the code. However, no new variables can be inserted/created here.
- Debug/programming modeThe editor supports two modes. In programming mode you edit worksheets. By attaching PLCnext Engineer to the running application process, the debug mode is activated. The debug mode assists you in carrying out function testing when commissioning the project by enabling you to display online values and execute debug commands.
Further Info
For information on commissioning the application and monitoring the application execution in debug mode, refer to the topic "Commissioning the Application: From Compiling to Debugging‣ Controller Commissioning: From Compiling to Debugging
×‣ Safety PLC Commissioning: From Compiling to Debugging
×".
Default text editor settings
The default settings for the text editor are defined in the 'Options' dialog that is opened by selecting 'Options' from the 'Extras' menu. In the 'Text Editor' group you can define the default settings for, e.g., the word wrap, the display of line numbers, the indentation, tab size, etc.
Split view
Splitting the editor worksheet allows you to view two areas of the same worksheet at the same time. When split, both areas can be scrolled independently. By dragging the split border (grey line between the two areas), the splits can be resized.
To split the worksheet, either double-click or drag the split icon on top of the right vertical scrollbar (see the first figure below). To cancel the split and show a single view, either double-click the split border or drag the split border to the top or bottom.
Expanded / collapsed editors area
PLCnext Engineer provides two possibilities for maximizing the editors area. Both are executed by the maximize icon which is available in each editor window (see (1) in the following figure) and in the tab bar of the editors area (2):
Maximize icon (1) enlarges the current editor window to fit the entire screen.
Icon (2) at the right side in the tab bar of the editors area maximizes the entire editors area including the editor group tab bar. This command is also available in the 'View' menu.
In both cases, PLANT and COMPONENTS are hidden. By hovering the mouse pointer to the title bar of the hidden PLANT or COMPONENTS area, it is expanded. Double-clicking an element in the expanded area first opens the related editors group and then hides the area again.
To exit the maximized editor mode, click the respective maximize icon again.
Note
Both maximize functions can be combined. |
Pin/unpin particular editors
You can open several editor windows in the editors area at the same by pinning them. Only if pinned, an editor window remains visible when another editor window is opened. If an editor window is unpinned, it disappears when you open another editor.
To pin an editor window, right-click the editor window tab and select 'Pin Editor' from the context menu. Pinned editors are marked with the pin icon on the tab. To unpin, select 'Unpin Editor' from the context menu. Both commands are also available as icons in the upper right corner of the editor window: and