Icon Using the Code Editor

While the designer handles the visual layout of controls in a visual client application, the code editor is where the actual functionality behind a form, database, or request handler is implemented. The code editor has the following layout:

Image

Warning Although all Unicode characters are supported in the code editor, certain double-wide characters in languages such as Chinese and Japanese cannot be displayed or edited properly at this time.

Automatic Code Updates
All component additions, modifications, and deletions are automatically reflected in the code editor by the IDE. For example, the following is the code editor showing the source unit of a new form:

Image

The following is the same source unit in the code editor after adding a TButton component.

Image

As you can see, the IDE automatically updated the source unit to include the proper declaration for the newly-added TButton component called Button1. If you then double-click on the Button1 component in the form designer, the source unit will look like the following:

Image

Again, the IDE has automatically updated the source unit to include an empty event handler for the TButton OnClick event. If you add code to the empty event handler, this code will then be executed when the button is clicked. For example, let's add a call to the ShowMessage procedure to display a message to the user:

Image

If you do not define any code or comments between the begin and end keywords that define the event handler code block, the IDE will automatically remove the event handler completely from the source unit the next time the source unit and form is saved.

Toggling Between the Code Editor and Designer
In order to toggle between the code editor and the designer, press the F12 key or click on the Code or Designer tabs in the lower left-hand corner of the work area in the IDE.

Key Mappings
The following key mappings are active in the code editor. Unless indicated otherwise, holding down the Shift key while pressing any of the keys that move the cursor position will cause any source code between the original and the final cursor position to be selected.

KeysAction
Up ArrowMoves the cursor to the previous line in the source code.
Down ArrowMoves the cursor to the next line in the source code.
Page UpMoves the cursor to the previous page in the source code.
Page DownMoves the cursor to the next page in the source code.
HomeMoves the cursor to the start of the current source code line.
EndMoves the cursor to the end of the current source code line.
Left ArrowMoves the cursor to the previous character on the current source code line.
Right ArrowMoves the cursor to the next character on the current source code line, or to the next line if at the end of the current source code line.
EnterInserts a new line at the current cursor position.
InsertToggles the insert/overwrite mode for the keyboard.
Shift-InsertPastes the source code contents of the clipboard, if any, into the current cursor position.
DeleteDeletes the character at the cursor position.
Shift-DeleteCopies the currently-selected source code to the clipboard and deletes the source code from the source code ("cut" operation).
BackspaceDeletes the character right before the cursor position. If the cursor is at the start of a source code line, then the current source code line is moved to the end of the previous source code line (if present).
TabInserts <tab size> spaces at the current cursor position, if the keyboard is in insert mode, or moves the current cursor position by <tab size> spaces if the keyboard is in overwrite mode. Please see the Modifying IDE Settings topic for more information on modifying the tab size used by the code editor.
Shift-TabRemoves <tab size> spaces working back from the current cursor position, if the keyboard is in insert mode, or moves the current cursor position to the left by <tab size> spaces if the keyboard is in overwrite mode. Please see the Modifying IDE Settings topic for more information on modifying the tab size used by the code editor.
Ctrl-HomeMoves the cursor to the first source code line.
Ctrl-EndMoves the cursor to the last source code line.
Ctrl-Page UpMoves the cursor to the first visible line on the current page.
Ctrl-Page DownMoves the cursor to the last visible line on the current page.
Ctrl-Left ArrowMoves the cursor to the start of the previous word in the source code.
Ctrl-Right ArrowMoves the cursor to the start of the next word in the source code.
Ctrl-Up ArrowScrolls the code editor window up by one line.
Ctrl-Right ArrowScrolls the code editor window down by one line.
Ctrl-EnterOpens the unit name or control interface name at the cursor position. If text is selected, then the selected text will be used first for searching for a valid unit name or control interface. If no text is selected, or the selected text does not represent a valid unit or control interface name, then the editor will use the identifier at the cursor position.
Ctrl-SpaceManually invokes code assistance at the cursor position. By default, code assistance is enabled so that it is automatically invoked after a specified delay (default 400 msecs). However, if code assistance is disabled, then you can still access the code assistance using manual key combination. Please see the Modifying IDE Settings topic for more information on enabling or disabling the code assistance in the code editor.
Ctrl-/Comments and un-comments (toggle) the current source code line.
Ctrl-InsertCopies the currently-selected source code to the clipboard.
Ctrl-BackspaceDeletes the word right on, or right before, the current cursor position. If the cursor is at the start of a source code line, then the current source code line is moved to the end of the previous source code line (if present).
Ctrl-ASelects all source code in the code editor.
Ctrl-CCopies the currently-selected source code to the clipboard.
Ctrl-IIndents the current source code line by <tab size> spaces. Please see the Modifying IDE Settings topic for more information on modifying the tab size used by the code editor.
Ctrl-NInserts a new line at the current cursor position.
Ctrl-TDeletes the word at the current cursor position.
Ctrl-UUn-indents the current source code line by <tab size> spaces. Please see the Modifying IDE Settings topic for more information on modifying the tab size used by the code editor.
Ctrl-VPastes the source code contents of the clipboard, if any, into the current cursor position.
Ctrl-XCopies the currently-selected source code to the clipboard and deletes the source code from the source code ("cut" operation).
Ctrl-YDeletes the current source code line.
Ctrl-Shift-YDeletes the source code from the current cursor position to the end of the current source code line.
Ctrl-ZReverses the last edit or find operation performed on the source code ("undo" operation).
Ctrl-Shift-ZReplays the last edit or find operation on the source code that was reversed ("redo" operation).
Ctrl-Shift-Down ArrowMoves the cursor from the class definition of a method to the implementation of the method.
Ctrl-Shift-Up ArrowMoves the cursor from the implementation of a method to its class definition.
F5Toggles a breakpoint for the current source code line (server applications only).
Ctrl-TabSelects the next source unit in the work area of the IDE, if one is present.
Ctrl-Shift-TabSelects the next source unit in the work area of the IDE, if one is present.
Ctrl-Shift-FDisplays the Find in Units dialog that allows you to perform text searches across all project source units, all open source units, or all source units in a specified path.
Ctrl-FShows the find toolbar at the bottom of the code editor. If the Find Text at Cursor option is enabled in the IDE, then the identifier at the current cursor position is automatically used as the search text. Please see the Modifying IDE Settings topic for more information on modifying the code editor search settings.
Ctrl-RShows the find and replace toolbar at the bottom of the code editor. If the Find Text at Cursor option is enabled in the IDE, then the identifier at the current cursor position is automatically used as the search text. Please see the Modifying IDE Settings topic for more information on modifying the code editor search settings.
Ctrl-GShows the goto line toolbar at the bottom of the code editor.

Context-Sensitive Help
You can get context-sensitive help on any keyword or identifier in the code editor by positioning the cursor over the desired keyword or identifier and pressing the F1 key. For more information on using the help browser, please see the Accessing Help topic.
Image