The Visual Studio editor provides a variety of features to boost your performance when writing COBOL code.
The defaults are aimed to help you when writing COBOL code. You can fine-tune the behavior of the editor and the productivity
features from
Tools > Options or by clicking
(Configure Micro Focus COBOL Text Editor Settings).
- AutoCorrect
- The AutoCorrect feature enables you to automatically correct your common typing mistakes. In the IDE preferences, you specify
a list of words that you sometimes mistype, and the correct spellings for them. When you type the misspelled versions in the
editor, AutoCorrect automatically corrects them.
Configure AutoCorrect from
Tools > Options > Text Editor > Micro Focus COBOL > AutoCorrect.
- Background Syntax Checking
- The COBOL code is checked in the background, as you type it. Any errors are underlined with wavy red lines. You can turn this
setting off or on the
Advanced page in
Tools > Options > Text Editor > Micro Focus COBOL.
Generally, we recommend that you leave Background Syntax Checking turned on as a number of IDE features rely on it and are
not available when it is disabled. You might consider turning it off only when editing exceptionally large files. See
Known Issues and Restrictions for more information about which IDE features areBookmark Window not available in that scenario.
-
- Shows the bookmarks added to source code in your solution. Choose
View > Bookmark Window to display the window.
- Bookmarks
- To add a bookmark, position the cursor on a line in the code and choose
Edit > Bookmarks > Toggle Bookmark.
- Brace completion
- A closing quote mark or bracket is automatically inserted when you type the opening quote mark or bracket at the end of a
line.
-
Call Hierarchy Window
- Either right-click in the editor and click
View Call Hierarchy or click
View > Call Hierarchy from the main menu.
-
Class View Window
- Shows an outline of the classes used in your solution and their members. To display the window choose
View > Class View. This applies to .NET COBOL projects only.
- COBOL Formatting
- Click
and either
Format COBOL Program or
Format
filename to apply consistent formatting and indentation to your sources. You can adjust your preferences for formatting from
.
- COBOL Margins
- The editor provides colorized margins for fixed and variable COBOL source code. You can specify whether to display or hide
the margins from the
Margins page in
Tools > Options > Text Editor > Micro Focus COBOL. You can change the color of the margins and the margin text from
Tools > Options > Environment > Fonts and Colors and then the
COBOL Margin and
COBOL Margin Text settings. The margins are automatically updated according to your preferences if the background parse is turned on.
- COBOL Reserved Words
- To configure the case of the COBOL reserved words used in the code snippets for COBOL choose
Tools > Options > Text Editor > Micro Focus COBOL > Code Style > Text Casing and set the case in the
Case format for reserved words field.
-
Code Definition Window
- If you position the cursor on an object in the source code, the
Code Definition Window automatically displays the section of the code implementing the objects referenced on that line. To display the window choose
View > Code Definition Window.
- Code Snippets
- Insert the code constructs for elements of the COBOL language, for example for classes, methods and delegates in .NET COBOL.
To insert a snippet choose
Edit > IntelliSense > Insert Snippet, or right-click in the editor and select
Insert Snippet, or type the shortcut for the particular snippet (for example,
class-id,
method-id) and press
Tab. This inserts an outline of the syntax for you to fill in. Snippets are available in both native and .NET COBOL code.
- To configure the case in which the code snippets are displayed choose
Tools > Options > Text Editor > Micro Focus COBOL > Code Style > Formatting and set the case in the
Case format for identifiers field.
- CodeLens navigation
- CodeLens is an adornment, either a clickable number of references or the information button,
, above paragraph and section names, class declarations, or Unit Test entry points. CodeLens enables you to explore the references,
or execute an action while positioned in the same place that you are editing.
For Micro Focus Unit Testing entry points, CodeLens displays the information button,
, that enables you to run or debug the test directly from that entry point in the editor
- Collapse to Definitions
- Click
Edit > Outlining > Collapse to Definitions
- Comments
-
- End-of-line comments - start end-of-line comments in the code using
*>.
- Comment out a line of code - for fixed or variable source format of code, enter
* in column 7 or, for FREE source format of code, enter
* in column 1 to comment out an entire line.
- XML documentation comments - in .NET COBOL , type
*>> to create Visual Studio-style XML documentation comments.
- Task List comments - to create Task List comments, type the declaration of a comment immediately followed by any of the following
phrases - TODO, HACK or UNDONE. To see the comments, check the
Task List window (click
View > Task List to show the window). The window shows all comments added in the files that have been opened in the editor and such that are
part of any copybooks referenced by these files.
To define other tokens as Task List comments or to change the priority of the comments, go to
Tools > Options > Environment > Task List.
To configure whether the IDE should display the Task List comments in the
Task List window, go to
Tools > Options > Text Editor > Micro Focus COBOL > Advanced and specify a preference for the
Show Comment Tasks option.
- Completion of statements
- When you start typing an IF, PERFORM or an EVALUATE statement, the editor automatically inserts the ending clause and aligns
the code in the statements.
- Editing Standalone Files
- This only applies to native COBOL. The recommended way to work with
Visual COBOL is to include all source files in a project because this enables full support for the IDE editing, compiling and debugging
features. There is limited support in the IDE for stand-alone files, such that are not part of a project and
Visual COBOL provides a path to create projects for these files in order to enable full editor, build and debug functionality. To create
a project from a stand-alone file, right-click in the editor and click
Create COBOL Project.
To edit a stand-alone file, first open it in the editor using
File > Open > File. Alternatively, double-click the file in Windows Explorer or start it from a command prompt. You can edit the file in the
usual way. Note, however, that background syntax checking is not available for standalone files so no errors are reported
as you type. You need to recompile in order for the IDE to check your code and report any issues.
When starting the IDE from the command line, also set the COBCPY environment variable to point to the folders where the IDE
should search for copybooks.
To specify the locations of any copybooks used in the stand-alone file when the copybooks are not in the same location, set
the COPYPATH Compiler directive in the IDE on the
Build Directives page in
Tools > Options > Micro Focus Tools > Standalone Editing as COPYPATH(<location1>;<location2>;...). You then need to recompile the file.
To specify non-default locations of copybooks, when opening the file from the command line also specify the COBCPY environment
variable as an argument at the command line and set it to point to the folders where the IDE should search for the copybooks.
Follow the
Single COBOL Files Support
link at the end of this topic for information about the level of support for stand-alone files.
- Editor Zoom
- Zoom in or out the text in the COBOL editor by pressing
CTRL and scrolling with the mouse.
-
Errors Window
- Shows the errors, warning and messages created when editing or compiling. Double-click on an item in the errors list to position
the cursor on the line of code that causes the error. You can get help on the error by pointing to the relevant error number
and pressing
F1.
- Expanded Copybook View
- To show the contents of a copybook inline in the place where the COPY statement is, right-click the line for the COPY statement
in the editor, and click
Show "copybookname".
To show all copybooks that are referenced in the file, either right-click in the editor, and click
Show all copybooks, or click
in the COBOL toolbar.
- Extract to Copybook
- Make a selection in the editor that includes the lines of code you want to move into a copybook, right-click the selection
and click
Extract to Copybook. This enables you to create a new copybook that includes the entire lines of code from your selection. In the editor, the
selected code is replaced by a COPY statement that refers the new copybook.
- Find in Files
- Click
Edit > Find and Replace > Find in Files (or press
CTRL+SHIFT+F).
To search in all copybooks - the ones that are part of the project as well as the ones that are found in the paths defined
on the
Copybook Paths tab in the project properties - set the search scope in the
Find and Replace dialog to
COBOL Project Copybook Paths.
This search in the COBOL program currently opened in the editor and in any copybooks referenced by that program, select the
Current COBOL Program option.
- Find All References
- In the editor, right-click a COBOL data item, a section or a paragraph name in the code and select
Find All References. A list of all places in the solution that contain the reference to the item is displayed in the
Find Symbol Results window. Double-clicking on an item in the list positions the cursor on the line of code that includes the element. The default
shortcut for invoking
Find All References is
Shift+F12. See
General Visual Studio IDE Issues for information about the limitations when using
Find All References.
-
Find Symbol Results Window
- To display the window, click
View > Find Results > Find Symbols Results. Displays the results of
Find All References command in the editor. Double-click an item in the list to position the cursor on the line that includes the referenced item.
- Format Document/Format Selection
- Changes the case of the source file currently opened in the editor or of a selection as specified on the
Formatting page in
Tools > Options > Text Editor > Micro Focus COBOL. To format the file or a selection of code, click
Edit > Advanced > Format Document or
Edit > Advanced > Format Selection.
- Go To Definition (F12)
- Pointing to a variable in the editor and pressing
F12 positions the cursor on the definition of that variable.
- Performing Go To Definition on a copybook name opens the copybook in the editor.
- Go To Line
- Click
Edit > Go To.
- Go To Previous Method / Go To Next Method
- Click
,
Go To Previous Method, or
,
Go To Next Method, in the COBOL toolbar to navigate easier in native Object-Oriented and .NET COBOL code. Alternatively, use the
Go To Previous Method and
Go To Next Method editor context menu commands.
- Go To Procedure Division / Go to Working-Storage Section
- The
Go To Procedure Division ,
, is available from the
Edit menu and on the
COBOL toolbar.
Click the downward arrow next to
in the COBOL toolbar to access the
Go to Working-Storage Section command.
- Click
to move the cursor following these rules:
- For procedural programs, the cursor moves to the first line of the Procedure Division of the COBOL source.
- For Object-Oriented programs, if the cursor is inside a class and before the method definitions, the command moves it to
the first line of the Procedure Division of the first method.
If the cursor is inside the methods declarations but outside a method, the command moves it to the first line of the Procedure
Division of the preceding method.
If the cursor is after a class, the command moves it to the first line of the Procedure Division of the last method of the
class.
- If the cursor is in a copybook file which you opened from Solution Explorer, the command moves it to the first line of the
Procedure Division of the first COBOL source that includes the copybook. If the copybook file was opened from a particular
COBOL file, the command moves the cursor to the first line of the Procedure Division of that COBOL file.
- IntelliSense
- Provides writing assistance in the editor. In both native and .NET COBOL, provides suggestions for COBOL words or snippets
when you press
Ctrl + Spacebar or start typing in the editor. In .NET COBOL, IntelliSense also displays lists of the namespaces, types, members and parameters
that are available when you type an object name followed by a space, dot, double colon or an opening bracket.
- Light Bulbs (Quick Actions) -
- Quick actions, also known as light bulbs, are a productivity feature of the Visual Studio editor that enables you to quickly
resolve some of the errors reported in your code such as to implement a missing piece of code or to find a copybook which
is not found in the projects copybook paths. The light bulb icon () appears when you hover the line of code which reports an error. Click the icon to view and select from the available actions
for resolving the issue.
- Locate definition
- (Locate definition) on the COBOL toolbar enables you to search for data items and identifiers by specifying any string of characters that might
be part of their name.
To return to where you were in the code, click
(Navigate Backwards) in the standard Visual Studio toolbar.
-
Navigate To
- Click
Edit > Navigate To to open a search widget.
Enables you to search for symbols and filenames and navigate to different locations of the current solution. Double-click
an item in the result to view the definition in the code.
Note: For .NET COBOL projects,
Navigate To search only works if at least one of the COBOL source programs has been opened in the IDE. For native projects,
Navigate To search only works only for the COBOL source programs that have been opened once in the IDE.
- Navigation Bar
- The navigation bar at the top of the COBOL editor displays the current project and file, and drop-down list showing the current
section and all objects and procedures used in the current program as well as the Procedure Division, any sections, paragraphs,
and group level data definitions. Use the right-hand drop-down to position the cursor on any of the objects or sections in
the file.
You can resize the drop-down fields such as if you want to hide one of them:
- Navigation using the Home and End keys
-
Pressing
Home repeatedly first moves the cursor immediately before the first non-white space in the current area, then at the beginning
of the area, or to the first non-white space in the preceding area.
Pressing
End repeatedly first moves the cursor immediately after the last non-white space in the current area, and then at the start of
the following area. You can change this default behavior from the
Tools > Options > Text Editor > Micro Focus COBOL > Margins page.
- Object Browser
- The
Object Browser window (click
View > Object Browser) enables you to explore the objects in your .NET COBOL applications. Click a node in the left pane of the Object Browser
window to see its members. Click a member in the pane in the top right corner to view the member's definition as provided
by its XML documentation comment in the code. Double-click a class or a class member in the Object Browser to navigate to
the definition of that class or member in the source files.
- Outlining
- Enables you to hide portions of the code. Choose
Edit > Outlining > Toggle Outlining Expansion.
- Override Class Members Wizard
- A user interface that facilitates you in overriding the members of an inherited class. To invoke the wizard, right-click inside
the class in the editor and choose
Snippet > Override Class Members. The wizard displays the members that you can override and which class they belong to. Select the members you want to override
and click
OK. This adds the selected methods with the
override modifier at the end of the class. Works with .NET COBOL code only.
- Peek Definition
- Right-click on a data item in the editor and click
Peek Definition. Opens a small window, embedded in the editor, showing the data item definition.
You can edit the code in the embedded window. You can also open several peek definition windows and use the breadcrumbs navigation
to switch between them.