Skip to main content
Version: 20

Code Editor

4D has a powerful built-in code editor that offers a wide set of features for highly productive code editing such as intelligent code completion, code navigation, debugging, searching, and more.

The Code Editor works much like a text editor. Writing a method or a class is usually a combination of typing text, selecting components, and dragging items from the Explorer or other windows. You can also use various type-ahead functions to create methods faster.

You can scroll through the contents of methods, classes and functions, which can include up to 32,000 lines of code or 2 GB of text.

The 4D Code Editor provides basic syntax error-checking. Additional error-checking is performed when the code executes. For more information on how to handle errors, see Debugging.



Each Code Editor window has a toolbar that provides instant access to basic functions related to code execution and editing.

Method executionexecute-methodWhen working with methods, each Code Editor window has a button that can be used to run the current method. Using the menu associated with this button, you can choose the type of execution:
  • Run new process: Creates a process and runs the method in standard mode in this process.
  • Run and debug new process: Creates a new process and displays the method in the Debugger window for step by step execution in this process.
  • Run in Application process: Runs the method in standard mode in the context of the Application process (in other words, the record display window).
  • Run and debug in Application process: Displays the method in the Debugger window for step by step execution in the context of the Application process (in other words, the record display window).
For more information on method execution, see Calling Project Methods.
Find in methodsearch-iconDisplays the Search area.
Macrosmacros-buttonInserts a macro at the selection. Click the dropdown arrow to display a list of available macros. For more information on how to create and instantiate macros, see Macros.
Expand all / Collapse allexpand-collapse-buttonThese buttons allow expanding or collapsing all the control flow structures of the code.
Method informationmethod-information-iconDisplays the Method Properties dialog box (project methods only).
Last clipboard valueslast-clipboard-values-iconDisplays the last values stored in the clipboard.
Clipboardsclipboard iconsNine clipboards available in the code editor. You can use these clipboards by clicking on them directly or by using keyboard shortcuts. You can use a Preferences option to hide them.
Navigation dropdowncode-navigation-iconsLets you navigate inside methods and classes with automatically tagged content or manually declared markers. See below

Editing area

This is where you write and edit your code. The editor automatically indents code text and colors the different syntax elements for clear code structure.

You can customize the display of the editing area. Any customization is automatically passed on to all the windows of the code editor:

OptionDescriptionSet in...
font and font sizeSets the character font and size to be used in the editing areaPreferences > Methods or Method > View > Bigger Font or Smaller Font
style and color of syntax elementsassign a specific color and/or style to each type of element of the 4D language. You can also change the different colors used in the interface of the editing area (highlighting, background, and so on).Right-click on a language element (variable, keyword, etc.) > Style submenu. Or Preferences > Methods
spacesYou can display the spaces between words using dots (.) instead of blank spaces. This option applies to all the code elements (command names, variables, comments, etc.).Method > View > White Spaces
themesYou can select the Dark or Light theme, or set a custom onePreferences > Methods
width of code indentationsSet the width of code indentationsPreferences > Methods

Change bars

Colored bars instantly show you where lines of code were modified since the method was opened:

The change bars change colors to indicate whether or not the modifications were saved:

  • yellow: Line was modified and method has not yet been saved.
  • green: Line was modified and method has been saved.

Lists area

The lists area lets you display one or more lists of elements necessary for writing methods and classes (commands, constants, forms, etc.). You can choose the number and contents of the lists displayed in the window.

By default, the Code Editor displays four lists. You can hide or show all lists by clicking on the icon at the botton right of the window.

You can enlarge or reduce the relative width of each list area by dragging one of its partitions. It is also possible to adjust the size of the list area in relation to that of the editing area by dragging the dividing line between them.

  • Double-clicking on an item in a list causes it to be inserted into the editing area, at the location of the cursor.
  • To modify the contents of a list, click on the title area of the list concerned: a pop-up menu appears, enabling you to choose the type of item to be displayed.

  • To add or remove a list, click in the title area of one of the lists and choose the corresponding command in the pop-up menu. The Remove this list command is disabled when you click on the last list. If you want to hide all the lists, you must either click on the show or hide lists button at the bottom right of the window or hide them by default in the Preferences.

  • You can hide the lists in all the windows in the following ways:

    • Select the View > Lists option in the Method menu (a check mark indicates whether lists are displayed)
    • Uncheck the Preferences > Methods > Options > Show Lists option. For the modifications made in the Preferences dialog box to be taken into account, any open methods, classes or functions must first be closed then reopened.

Available lists of items

You can display the following lists of items in the lists area of the Code Editor window:

  • All tables and fields: Database table and field names in the form of a hierarchical list. When you insert a field name into the method by double-clicking on its name, 4D inserts it while respecting the syntax and adds the name of the table or subtable as the case may be.
  • Table (submenu): Field names of the table selected using the submenu.
  • Current table: Field names of the current table (available in triggers, form methods and object methods).
  • Project forms: Database project form names. When you double-click on a project form name, 4D inserts its while respecting the syntax: the form name is inserted between quotes.
  • Table forms: Database table and form names in the form of a hierarchical list. When you insert a form name into a method by double-clicking its name, 4D inserts it while respecting the syntax: the form name is inserted between quotes and is preceded by the name of the table and a semi-colon. For example: [Table];"Form".
  • Methods: Database project method names.
  • All folders: Names of object folders and subfolders set in the database displayed in the form of a hierarchical list. Folders can be used to organize objects in a customized manner. They are managed from the Home Page of the Explorer.
  • Folders (submenu): Contents of the folder selected using the submenu.
  • Macros: Macro names defined for the database (see Creating and using macros).
  • Commands: 4D language commands in alphabetical order.
  • Commands by themes: 4D language commands classified by theme in the form of a hierarchical list.
  • Menu bars: Names and numbers of menu bars created with the 4D Menu bar editor.
  • Constants: 4D constants and those of any plug-ins, classified by theme in the form of a hierarchical list.
  • Lists: Names of lists.
  • All plug-in commands: Commands for all the plug-ins installed in the database (if any), classified by theme in the form of a hierarchical list.
  • SQL Keywords: set of keywords recognized by the 4D SQL syntax parser. This list includes commands (e.g. SELECT), clauses (e.g. WHERE) as well as functions (ABS).
  • SQL Functions: 4D SQL functions.

Note: Except for the Macros element, all the lists are in alphabetical order.

Save as template

You can save the lists set in the Code Editor window in the form of a template. Once the template is saved, the parameters set in it will be used for each new Code Editor window that is opened.

The following parameters are stored in the template:

  • Relative size of the editing and list areas
  • Number of lists
  • Location and contents of each list
  • Relative width of each list

To save a Code Editor window as a template, choose Method > Save As Template. The template is saved immediately (no dialog box appears). It is stored in the Preferences of the 4D application. If a previous template already exists, it is replaced.

Break points area

This area, located to the left of the editing area, allows you to display the line numbers and to insert break points directly next to specific instructions. Break points are useful during the debugging phase of your programming. They stop the execution of your code at specific locations and display the debugger.

For more information on break points, see the Debugging section.

You can display or hide the line numbers in the break points area for each window of the Code Editor.

  • To enable or disable the display of line numbers by default, choose Preferences > Methods > Show line numbers.
  • To modify this display separately for each window of the Code Editor, choose Method > View > Line Numbers.

Displaying the line numbers makes it easier to find your way around in the window. The Method > Go to Line Number... command in the also lets you take advantage of this display.

This type of search is useful when used in conjunction with the compiler, which flags runtime errors by the line number in which they occur.

Status bar

The status bar located at the bottom right part of the editor window displays the position of the cursor at all times:

  • Ln: Line number
  • Col: Column number, i.e., the level in the hierarchy of programming structures. The first level is 0. The column number is useful for debugging since this information can be provided by the interpreter in the event of an error in the code.
  • Ch: Location of character in the line.
  • : Hide/display lists.

When you set the cursor in a command, function or parameter(s), the status bar displays the syntax of the command. If you write or select a parameter, the area shows the current parameter in bold:

The navigation dropdown helps you organize your code and navigate more easily inside your classes and methods:


Some tags are added automatically, and you can complement the dropdown list using markers.

Code navigation

Click an item in the dropdown list to go to its first line in the code. You can also navigate with arrow-keys and press Enter.

Automatic tagging

Constructors, method declarations, functions and computed attributes are automatically tagged and added to the dropdown list.

When there is no tag in the class/method, the tool displays "No tag".

The following items are added automatically:

no-tag-iconNo tag
constructor-iconClass constructor or method declaration
computed-attribute-iconComputed attribute (get, set, orderBy and query)
function-iconClass function name

Manual tagging

By adding markers in your code, you can add the following tags to the dropdown:

mark-tag-iconMARK: tag
todo-tag-iconTODO: tag
fixme-iconFIXME: tag

You declare them by adding comments such as:

// FIXME: Fix following items

Declarations are not case-sensitive; writing fixme: has the same effect.

Adding a hyphen after the MARK: tag draws a separating line in the code editor and the dropdown menu. So writing this:


Results in this:


All markers located inside functions are indented in the dropdown list, except for the MARK: tags located at the end of functions and not followed by instructions. Those will appear at the first level.

Display order

Tags are displayed in their appearing order inside the method/class.

To display the tags of a method or class in alphabetical order, do one of the following:

  • right-click the dropdown tool
  • hold Cmd on macOS or Alt on Windows, and click the dropdown tool

Tags inside functions move with their parent items.


Multiple features of 4D's Code Editor are available through default keyboard shortcuts.


Under macOS, use the Command key instead of the Ctrl key mentioned (Windows).

Selection and navigation
Double-clickSelect a language element name
[Alt]+Double-clickSelect a language element name contaning spaces (constant, method, etc.)
[Shift]+[right arrow]Create and enlarge the selection, character by character, to the right, or Reduce the selection, character by character, from the left
[Shift]+[left arrow]Reduce the selection, character by character, from the right or Create and enlarge the selection, character by character, to the left
[Shift]+[down arrow]Create and enlarge a selection, line by line, from the top to the bottom
[Shift]+[up arrow]Create and enlarge a selection, line by line, from the bottom to the top
[Ctrl]+[Shift]+[right arrow]Create and enlarge the selection, word by word, from the right
[Ctrl]+[Shift]+[left arrow]Reduce the selection, word for word, from the right, or create and enlarge the selection, word by word, from the left
[Ctrl]+[right arrow]Move the insertion point, word by word, from left to right
[Ctrl]+[left arrow]Move the insertion point, word by word, from right to left
[Alt]+[down arrow]Move the line(s) where the cursor is to the bottom
[Alt]+[up arrow]Move the line(s) where the cursor is to the top
[Home]Place the insertion point at the beginning of the line
[End]Place the insertion point at the end of the line
[Ctrl]+[Home]Place the insertion point at the beginning of the method
[Ctrl]+[End]Place the insertion point at the end of the method
[Shift]+[Home]Select all the characters in the line that are to the left of the cursor
[Shift]+[End]Select all the characters in the line that are to the right of the cursor
[PgUp]Scroll the contents of the method, page by page, from the bottom to the top (doesn't modify the insertion point)
[PgDn]Scroll the contents of the method, page by page, from the top to the bottom (doesn't modify the insertion point)
[Ctrl]+K or [Alt]+double-clickSame as Goto definition command
[Ctrl] (Windows) or [Alt] (macOS)+hovering over a tokenUnderline the token (identified language element). Click on the underlined token = same as Goto definition command
Find and replace
[Ctrl]+GFind Next
[Ctrl]+[Shift]+GFind Previous
[Ctrl]+EFind Same Next
[Ctrl]+[Shift]+EFind Same Previous
[Ctrl]+[Alt]+GReplace Next
[Ctrl]+[Alt]+[Shift]+GReplace Previous
[Shift]+click or [Alt]+click on clipboard iconCopy selected text to a clipboard
[Ctrl]+[Shift]+number keyCopy selected text to the number clipboard
[Ctrl]+click on clipboard iconPaste contents of a clipboard at cursor location
[Ctrl]+number keyPaste contents of the number clipboard at cursor location

Most of these shortcuts can be customized in the 4D Preferences dialog box.

Editing Code

4D uses standard text editing techniques for typing and editing in the Code Editor.

The Code Editor uses display conventions (style, color) for the syntax elements. You can customize these conventions. As you type, when you validate your entry, 4D evaluates the text of the line and applies the appropriate display format. 4D also indents each line to its proper level in relation to the preceding line when you use programming structures (If, End if...).

You can use the arrow keys to move from line to line quickly. Using the arrow keys to move across several lines is quicker than clicking because the editor delays evaluating the line for errors.

Under Windows, the code editor includes an Input Code Editor (IME) to facilitate code editing on Japanese or Chinese systems.

The Code Editor includes numerous navigation shortcuts.

Using the backslash

The backslash character (\) has a specific support in the 4D language:


The backslash character (\) is used as a separator in pathnames under Windows. In general, 4D will correctly interpret Windows pathnames entered in the Code Editor by replacing the single backslash \ with a double backslash \\. For instance, C:\MyDocuments will become C:\\MyDocuments. However, if you write "C:\MyDocuments\New", 4D will display "C:\\MyDocuments\New". In this case, the second backslash is interpreted incorrectly as \N (an existing escape sequence). You must therefore enter a double backslash \\ when you want to have a backslash in front of a character used in one of the escape sequences recognized by 4D.


From the Explorer, you can drag and drop tables, fields, forms, project methods, constants, or 4D commands. When you drag and drop an element, 4D always uses the correct syntax. For example, if you drag the field name First Name from the [People] table, it appears in the Code Editor as [People]First Name. Similarly, if you drag the Form name Input from the People table, it appears in the Code Editor as [People];"Input".

When you insert a command by dragging it from the Commands page of the Explorer, it appears with its syntax (which consists of all of its parameters) in the Code Editor. This feature simply reminds you of the parameters that the command expects. You can then use a syntax that better suits your usage.

You can also drag-and-drop within a method, class, function or between two different ones. In the Code Editor, the drag-and-drop mechanism is activated as soon as a portion of text is selected. By default, the drag-and-drop mechanism moves the selected text. In order to copy it, hold down the Ctrl key (Windows) or the Option key (macOS) during the operation.

Changing case

You can automatically modify the case of selected characters using the commands in Methods > Case or the context menu of the editor:

  • Uppercase / Lowercase: Switch the selected characters to uppercase or lowercase.
  • camelCase / CamelCase : Switch the selected characters to "camel case". This consists in changing each first letter of a group of attached words to uppercase. This type of notation is often used for variable nomenclatures. hireDate and PurchaseDate are examples of two variants of camel case notation.

When you apply one of these commands to a text selection, the spaces and "_" characters are removed and the first letter of each word becomes uppercase.

Swap expression

The Swap Expression function can be used to reverse the arguments of an expression assigning a value. For instance,




This function is extremely useful for reversing a set of assignments used to get or set properties, or to correct input errors. To use this function, select the line(s) to be modified, then choose Method > Swap Expression or use the context menu of the area. Within the selection, only the lines assigning a value will be modified.


In addition to the standard copy-paste operation, 4D offers two additional functions that let you work with the contents of different clipboards:

  • The program stores the last 10 "copy" or "cut" actions that were performed in the Code Editor in memory during the current session. Each of the different contents saved in this way can be reused at any time. To do this, use the Clipboard History command of the Code Editor context menu or the "Last Clipboard values" button of the toolbar:

    The first few words of the copied or cut items are displayed. Select an item to insert it at the current location of the cursor.

  • Nine additional numbered clipboards are available and can be employed directly using the buttons of the Code Editor toolbar or using keyboard shortcuts:

Moving lines

You can move the line where the cursor is directly without selecting it first using the Move Lines Up and Move Lines Down commands in the Method menu. You can also do this using the Alt/Option + Up Arrow or Down Arrow keyboard shorcut.

Autocomplete functions

The Code Editor provides autocomplete functions. 4D automatically displays suggestions based on the first few characters typed.

In the example given below, typing the string "cop" causes the display of a blue triangle indicating that several suggestions are available:

When the characters you enter correspond to a single possibility, this suggested value appears greyed out (and is inserted if you hit the Tab key): --->

If you checked the Insert () and closing } ) ] " option in the Methods page of the Preferences, 4D will also automatically add () after a 4D command, keyword or project method that requires one or more mandatory arguments (after accepting a suggestion or completion): ->

Autocompletion also works with code structures (e.g. If..End if, For each...End for each): when you enter the first part of the structure, the Code Editor will automatically suggest the closing part:

If there are several suggestions available, 4D displays them in a pop-up list when you hit the Tab key:

The list is in alphabetical order. Choose the value by double-clicking it or scroll the list using the arrow keys of the keyboard and then hit Enter, Carriage Return or Tab to insert the selected value.

By default, you can also insert a suggested value by hitting one of the following delimiter ( ; : = < [ { keys after selecting a value: the value inserted is then followed by the delimiter, ready for data entry.

+ ( key -->

You can disable the use of delimiters for inserting suggested values in Preferences > Methods > Options.

You can press the Esc key to close the pop-up list or you can continue typing while it is open. The values suggested in the pop-up list are updated as additional characters are typed.

If the characters typed correspond to different types of objects, the list displays them in their current style. The following types of objects can be displayed:

  • 4D commands
  • SQL commands
  • User methods
  • Table names
  • Field names
  • Constants
  • Local, process or interprocess variable, declared in the method
  • Object property names
  • Plug-in commands
  • 4D keywords
  • SQL keywords
  • Macros (displayed between < >)

For practical reasons, you can disable the automatic display of the list of suggestions for constants, (local or interprocess) variables and object attributes and/or tables. These options are found in Preferences > Methods > Options

Object property names

4D automatically displays case-sensitive suggestions of all valid object property names in 4D code when you:

  • type a dot "." after an object or
  • use the Tab key after a dereferenced object pointer "->".

The length property is always included for use with collections.

Once created, property names are stored in an internal global list and are available anytime a method/class/function is opened, closed or changes focus.

The list of suggestions is dynamically updated while you edit code. When switching between windows, new/edited property names are always added to the global list. The list is also updated when you preview a method, class or function in the Explorer.

When the database is restarted, the list is reinitialized.

You can disable the automatic display of object properties in Preferences > Methods > suggestions.

Find and replace

The Code editor has powerful find and replace features that apply to the current window.

A search and replace area can be displayed in the toolbar of any method window:


To display this area, click on the Find in method icon of the toolbar or select a find or replace function either through a shortcut or a command from the Edit > Find submenu. You can close this area at any moment by clicking on the x button at the rightmost side of the toolbar.


The Find in Design feature in the 4D toolbar or in the Edit menu is not specific to the Code editor but may be used to search for a value among all the methods and classes.


Select Find > Find... in the Edit menu or type Ctrl+F (Windows)/Cmd+F (macOS) to display/enable the Search area.

The search defined in this area will be performed in the code located in the window.

The find entry area enables you to enter the string to be searched for. This area is a combo box that stores the last 10 strings that have been searched for or replaced during the session. If you highlight text before choosing the Find... command, it will appear in this area. You can then either use this text or replace it with another.

Once a string is entered or selected, all occurrences found in the opened window are highlighted and the right side of the area displays the total number of hits found. It also indicates the current position of the cursor among all hits.

Hit the Enter key to select closest occurrence to the cursor. You can also click on the Next / Previous buttons find-next-previous to select all occurrences sequentially towards the beginning or end of the current method, starting from the initial location of the cursor, or use the Find Next and Find Previous commands of the Edit menu.


  • Case Sensitive case-sensitive: Take the case of characters as they were entered in the find area into account. This option also takes into account diacritic characters. For instance, a search for "MyVar" will not find "myVar"; a search for "dej" will not find "déjà".
  • Whole Word full-word: Limit the search to exact occurrences of the word being searched for. When this option is checked, for instance, a search for "client" will not find either "clients" or "myclient." By default, this option is not checked; therefore, a search for "var" will find "Myvar," "variation," etc.


Click on the v toggle button on the left side of the Search area to display/hide the Replace area. You can also select Find > Replace... in the Edit menu or type Ctrl+Alt+F (Windows)/Cmd+Alt+F (macOS) .

The Replace entry area is used to define the character string that will replace the one defined above.

Click the Replace button to launch the search with all defined options and replace the first occurrence found. 4D begins searching from the current text insertion point and continues to the end of the method. It is then possible to continue finding/replacing using the Replace Next and Replace Previous commands of the Edit menu.

Click the Replace all button to replace all the occurrences corresponding to the search criteria directly in the open method.

Find Same

The Find Same command is used to find character strings identical to the one selected. This command is only active if you have selected at least one character in the Code Editor.

The search carried out is of the "Find Next" type in the current code editor window.

The Find Same Next and Find Same Previous commands are used to find character strings strictly identical to the ones selected. For example, the case must match.

Bookmark All

The Edit > Bookmark All command is enabled when a search has already been specified in the find or replace dialog box. When you select this command, 4D puts a bookmark at each line that contains an item corresponding to the "current" search criteria. This makes it easy to spot all the search results. For more information about bookmarks, refer to Bookmarks.

Syntax errors

4D automatically checks the method syntax to see if it is correct. If you enter text or select a component that is not syntactically correct, 4D displays a symbol to indicate the incorrect expression . When you move the mouse over the symbol, a help tip displays the cause of the error:

When entering code, you can immediately check the syntax of the current line (without advancing to the next line) by pressing the Enter key on the numeric keypad. 4D evaluates the line, formats it, marks any errors, and places the insertion point at the end of the line. When a line of a method, class or function is marked as having improper syntax, check and fix the entry. If the line becomes correct, 4D removes the error symbol. When you save or close the window, the entire method is validated. You can also force validation by pressing the Enter key.

When the method, class or function is validated, 4D checks for:

  • basic syntax errors
  • the structure of statements (If, End if and so on)
  • matching enclosing characters in the code such as parentheses or quotation marks. When you type an enclosing character, 4D indicates the match by framing the start/end characters with gray rectangles:

If you click on an enclosing character in the code, 4D indicates its match with gray rectangles by default. You can modify the way 4D indicates matching enclosing characters or disable this feature in Preferences > Methods > Options > Matching parentheses.

The Code Editor can only check for obvious syntax errors (misspellings and the like). It does not check for errors that only occur during execution. Execution errors are caught by 4D when the code is executed.

4D has a built-in debugger (see Debugging) for handling and correcting these errors. The compiler also provides indispensable help for detecting errors. For more information about the compiler, refer to the Compilation chapter.

Help tips

The Code Editor provides various contextual information using help tips. They appear when you mouse over an object.


The status bar also provides contextual information.

  • Errors: When you mouse over the symbol indicating an error to the left of the editing area, a help tip displays the cause of the error (see Syntax errors).

  • 4D command documentation: When you move the mouse over a 4D command or function, a help tip provides its syntax along with a brief description of how it works.

  • Variable type and description: When you mouse over a variable, a help tip shows its type (if it has been explicitly defined in the method) and associated comment, if any.

  • Project methods or functions: When you mouse over a project method or class function, a help tip displays:

    • either the comments specified in the Explorer.
    • or the first few lines of the method or class function if it includes comments (lines beginning with // or /.../ comment block). It is common practice to insert documentation for the method as well as its parameters in the form of comments at the beginning of the method. You can get this information directly in the help tip, just make sure to first remove any comments found in the Explorer. Comments at the beginning of a method: Help tip in another method:
  • You can also create a dedicated documentation file named <MethodName>.md in the <package>/documentation folder. See Viewing documentation in the code editor

Comment / Uncomment

The 4D language supports comments, which are inactive lines of code. The code editor does not apply any particular style within comments. The length of comments is limited to the maximum size of 32,000 characters per line.

There are two kinds of comments: //comment (single line comment) and /*comment*/(inline comments or multiline comment blocks).

Comments can be created by typing / characters. Or, the Comment/Uncomment command, found in the Method menu as well as in the Code Editor context menu is used to mark a group of selected lines of code as single line comments, or, on the contrary, to remove the single line comment characters from a selection. To use this command, select the code to be marked as commented, then select the Comment/Uncomment command:


When the selection contains only active code, the Comment command is applied. When the selection includes both active code and commented lines, an additional pair of comment characters ( // ) is added to the latter; this way, they will retain their initial commented status if the line is subsequently "uncommented." When the selection contains only commented lines, the Uncomment command is applied.

The Comment/Uncomment command only operates with full lines --- it cannot be used to comment only part of a line.

Expand / Collapse

4D code located inside loops and conditions can now be collapsed or expanded, in order to facilitate the reading of methods:

  • Expanded code:

  • Collapsed code:

If you place the mouse over the expand button [...], a help tip appears, displaying the first lines of the hidden code.

A collapsed portion of code can be selected, copied, pasted or deleted. All the lines included therein will be copied, pasted or deleted respectively. When a portion of code is pasted, it is automatically expanded.

There are several ways to expand and collapse code:

  • Click on the expand/collapse icons ([+] and [-] under Windows) or on the opening button [...]

  • Use the commands of the Method > Collapse/Expand submenu:

    • Collapse Selection / Expand Selection: collapses or expands all the code structures found in the text selection.
    • Collapse Current Level / Expand Current Level: collapses or expands the code structure at the level where the cursor is located. These commands are also available in the context menu of the editor.
    • Collapse All / Expand All: collapses or expands all the loops and conditions of a method. These commands are also available in the toolbar of the editor.


Blocks can be defined by:

  • Quotation marks
  • Parentheses
  • A logical structure (If/Else/End if, While/End while, Repeat/Until Case of/End case)
  • Braces

Select Enclosing Block

The Select Enclosing Block function is used to select the "enclosing block" of the code containing the insertion point.

If a block of text is already selected, the function selects the enclosing block of the next highest level and so on, until the entire method is selected.

Pressing Ctrl+Shift+B (Windows) or Command+Shift+B (macOS) enables you to reverse this operation and deselect the last enclosing block selected.

Note: If the insertion point is placed in an If or Else type structure, the enclosing block will be the one containing, respectively, the If or Else statement.

Start of Block or End of Block

Two commands make it easier to move around within code structures (e.g. If...Else...End if):

  • Start Of Block: places the cursor at the start of the current structure, just before the initial keyword.
  • End Of Block: places the cursor at the end of the current structure, just after the final keyword.

These commands are found in the Method menu as well as the context menu of the editor. You can also use the following shortcuts:

  • Windows: Ctrl + up arrow or Ctrl + down arrow
  • macOS: Command + up arrow or Command +down arrow.


4D lets you associate bookmarks with certain lines in your methods. You can then browse quickly within the code by passing from one bookmark to another using specific commands.

A bookmark moves along with its original row if additional rows are inserted in the method. Bookmarks are saved with the methods.

Bookmarks are managed using the Bookmarks submenu of the Method menu:

  • Toggle: Associates a bookmark with the current line (where the cursor is located) if it does not already have one or removes the existing bookmark if it does. This function is also available using the Toggle Bookmark command of the editor's context menu or using the Ctrl+F3 (Windows) or Command+F3 (macOS) keyboard shortcut.
  • Remove All: Removes all bookmarks from the foreground window.
  • Goto Next / Goto Previous: Enables browsing among bookmarks in the window. Selecting one of these commands places the cursor on the first character of the line associated with the bookmark concerned. You can also use the keyboard shortcuts F3 (go to next) or Shift+F3 (go to previous).

You can use bookmarks as markers for lines that contain an item found by a search. In this case, 4D automatically adds the bookmarks. For more information, refer to Bookmark all.

Reveal in Explorer

The Reveal in Explorer... command opens an Explorer window with the target element selected. To do this, place the cursor inside the element's name or select it, then choose Method > Reveal in Explorer... .

Search Callers

The Search Callers command in the Method menu is only enabled for project methods. It searches for all the objects (other methods or menus) that reference the project method.

Note: The Search Callers... command is also available in Explorer > Methods

This command displays its results in a new window.

Goto Definition

The Goto Definition command opens the definition of an element referenced in the Code Editor. To do this, place the cursor inside the object name or select it, and choose Method > Goto Definition... or use the context menu of the editor.


This feature is also available through the keyboard shortcut Ctrl+K (Windows) / Command+K (macOS) or Alt+double-click.

The effect of the Goto Definition... command varies depending on the target element:

  • with a project method, it displays the contents of the method in a new window of the Code Editor
  • with a class name or class function, it opens the class in the the Code Editor
  • with a built-in 4D command or function, it has the same effect as the Show documentation command.

Show documentation

The Show documentation... command opens the documentation for the target element. To do this, place the cursor inside the element's name or select it, then choose Method > Show documentation... or use the contextual menu. The effect varies depending on the target element. For example:

  • Selecting a project method or a user class and choosing Show documentation... selects the method in the Explorer and switches to the documentation tab
  • Selecting a 4D command, function, or class name and choosing Show documentation... displays the online documentation.
  • If no element is selected, the command opens the documentation of the method currently opened in the Code Editor, if any.

To display the documentation of a 4D "classic" language command, select the command name or simply place the cursor in the name and press F1. The documentation of the command is displayed in a new window of your default browser. 4D looks for the documentation depending on the settings made in the Preferences (see Documentation location).

Search References

The Search References... command found in the Method menu or the context menu of the Code Editor finds all the objects (methods and forms) in the project where the current item of the method is referenced (used).

The current item is either the one selected or the one where the cursor is located. It can be a field name, variable name, command, string, and so on. For example, the following action looks for all the occurrences of the vlNbCmd variable in the database:


This command displays its results in a new window.