The IDL Workbench > Editor View

# The Editor View

In this Workbench view, you can write, edit, and debug IDL programs. An example of a file opened in the editor view is shown below:

Breakpoints - The red circle in the in the vertical gray bar to the left of the line numbers (above) is a breakpoint. These can be added by double clicking in the gray column next to your code. Breakpoints halt execution of your code.

Line Numbers - The line numbers do not appear by default. To turn line numbers on (see screenshot, above) , right click in the white column directly to the left of the code and select "Show Line Numbers" from the menu.

Bookmarks - Bookmarks are short placeholders you can set within your code (see figure, above) and are used to navigate to resources that you frequently use. When a Bookmark is set, a blue icon shows up to the left of the line numbers but do not affect how your code compiles or runs. To set a bookmark, right-click in the gray column to the left of the line numbers and choose "Add Bookmark." Enter a name for the Bookmark and select "OK". See Bookmarks View for more information on using Bookmarks.

Note: Bookmarks are only available when a file is part of a project.

Tasks - Allow you to set reminders for things you need to do in your code. When a Task is set, a small checkmark icon will appear to the left of the Editor's line numbers (see figure, above). Tasks do not affect how your code runs. To set a Task, right-click in the gray column to the left of the line numbers and choose "Add Task." Enter a name for the Task in the "Description", choose a priority, and select "OK".

Note: Tasks are only available when a file is part of a project.

## Opening a File

You can choose from among several ways to open files for editing. Note that each program file you open will appear in a separate tab in the Editor view.

- Select FILE > Open from the Workbench's Menubar to open a dialog allowing you to browse to and select a file to open.
- From the Project view, drag and drop one or more files or .PRO files to the Editor View.
- In the Project View, double-click on the name of a .PRO file.
- Drag and drop files from your system's file browser to the Editor View (i.e., Windows Explorer or the equivalent file browser on UNIX or Mac).
- In the IDL Console, type `.edit <program name>` or `.compile <program name>` at the IDL command line and it will open in the Editor view. The file must be in your search path or in your Console's current directory. To add a directory to your path, select WINDOW > Preferences > IDL > Paths or change the current directory in the IDL Console View)

## Tips and Tricks for the Editor

### Help

- Window Size: You can use <CTRL><M> to maximize/minimize the editor window.
- Hover-help: You can also place the mouse cursor over a routine call that will display the help information about the routine.
- IDL Help: Press <F1> to bring up the IDL Help.
- Help entry for a routine: Place your cursor on the name of a routine, press <F1> (Windows), <SHIFT><F1> on Linux, or <COMMAND><F1> on a Mac to open the IDL Help entry for the routine.

### Formatting

- Code templates help you stub out a procedure, function, or class. These are user-configurable under: WINDOW > Preferences > IDL > Templates. Access code templates one of two ways. Start typing the name of a routine or function (i.e., "CASE"), then either:
  - <right-click>, select Code Templates, then select the template you want to insert.
  - or <CTRL><SPACE>, then select the template you want to insert from the dialog.
- Insert an IDLDOC header, pre-populated with tags based on a user-defined template, using <CTRL><SHIFT><I> (definable in Preferences). Note that this is for routines only.
- The Workbench automatically closes all compound statement blocks (i.e., the IF statement gets an ENDIF automatically).
- The Toggle Comment feature comments/uncomments the current line or selected block of code (<CTRL><;> or SOURCE > Toggle Comment).
- Auto Indent: After typing a line of code, hitting <ENTER> will cause auto-indent of the next line by one tab. Set behavior inside of Preferences.
- Auto Format (Pasting Code): If you paste a block of code into the Editor, Auto Formatting will indent it for you as you paste. Set the behavior of this feature inside of Preferences.
- Auto Format (Selected Code): If you select a block of code in the Editor, press <CTRL><SHIFT><F> to automatically format it (or choose SOURCE > Format from the Menubar).

### Miscellaneous

- Open Source Code: Use <CTRL><left mouse click> on a call to a user-defined routine to open its source code in a separate Editor tab.
- Find Files with Open Resource: Press <Ctrl><Shift><R> to bring up Open Resource. Start typing in the text box at the top of the window (wildcards are OK), and the window will incrementally display and filter down a list of every matching file in your open projects. Press <ENTER> to open the top item in the list. Open Resource also works well for opening multiple files with similar names. Open Resource only searches the files found in your IDL Workbench's Project Explorer.
- Cycle through the open tabs in your Editor with <CTRL><F6> or <CTRL><PgUp>/<CTRL><PgDown>.
- Line Numbers: Toggle the visibility of the line numbers by right-clicking in the left gray column of the Editor.
- Auto Highlight: Click on any word in your Editor to highlight it, as well as other occurrences of the word in the current file. Use <F3> to cycle through the occurrences. Matches to selections in the file will be highlighted. For example, selecting "print" in line 4 of the screenshot, would also cause the Workbench to highlight "print" in line 11.
- Drag and Drop lines of code from Command History View into the Editor to help create programs from statements entered at the command line. Select multiple lines by holding down the <CTRL> or <SHIFT> key while highlighting.
- Run Selected Text: Select a block of text in the Editor and <SHIFT><F8> or <right-click><Run Selected Text> to run the text as if you had typed it at the command line. Helpful while building or debugging code.
- Syntax Coloring: Code in the Editor view is colored according to the following defaults (configurable in Preferences under WINDOW > Preferences > IDL > Syntax Coloring):
  - Forest Green - Comments
  - Bright red - Strings
  - Olive green - Numbers
  - Black - Structure fields
  - Brick red - Reserved Words
  - Dark blue - System procedures
  - Bright blue - System functions
  - Sea Green - User procedures
  - Aqua - User functions
  - Black - Plain Text

## See Also

Class Hierarchy, Command History, Console View, Preferences, Menubar and Toolbar, Outline View, Problems View, Profiler View, Project Explorer, Workbench Overview, Variables View