Accelerate Code Development in the Editor

The IDL Editor provides integrated features to help you organize and accelerate code development. This section describes IDL Editor features, including Content Assist, Key Bindings, and Commenting Code.

Content Assist

Content Assist helps you quickly access context-sensitive help for procedures, functions, methods, executive commands, templates, and variables. You can call Content Assist in the following ways:

All IDL Elements

To see how this works, open a new file by clicking the ed_open_file.gif icon or choosing File →  New → Untitled Text File. On a blank line, call Content Assist. The pop-up menu displays every available IDL element. Scroll down to view the entire list or type the first few letters of the element that you want to add.

ed_contentassist.gif

Routines and Functions

Now try typing con on a blank line and then Ctrl+Space. The Content Assist window displays only routines and functions that begin with "con."

ed_contentassist02.gif

Note
Functions display with the letter "F" in the icon.

Functions Only

A third experiment is to type x=con and then Ctrl+Space. Now the Content Assist window displays only functions that begin with "con."

ed_contentassist03.gif

See Content Assist in the "Welcome to the IDL Workbench" documentation.

Structure Variables

Type !version. to display a list of structure tags.

ed_hoverhelp04.gif

Variables in the Current Scope

You can quickly assign the value of one variable in the current execution scope to another using content assist. To see this, do the following:

  1. At the IDL Command prompt, enter
  2. my_very_long_variable=99 
    
  3. Now type
  4. new= 
     

    and press then Ctrl+Space. You will see a list of IDL variables and functions. Begin typing "my_very_long_variable" to see the list of items reduced until your variable name is selected.

While IDL System variables (like !version, shown above) are available in any execution context, normal data variables are only available in the IDL execution scope in which they exist.

Word Completion

Use Word Completion to speed up code development. In theIDL Editor, begin typing a word, then press Alt+/ to complete the word (Ctrl+. on the Mac). The Editor proposes word completions for the current string based on all words found in any open editor.

Key Bindings

The term key binding refers to a keyboard shortcut, a command assigned to a keystroke or a series of keystrokes. The IDL Workbench comes with a useful set of key bindings to help you save time.

A list of all available key bindings displays when you press Ctrl+Shift+L in the IDL Editor, as shown here:

ed_key_bindings.gif

With the key bindings list displayed, press Ctrl+Shift+L again to customize the key binding preferences.

For more information on customizing key binding, see "Key Strokes, Key Sequences, and Key Bindings."

Commenting Code

The semicolon (;) is the comment character in IDL. When IDL encounters the semicolon, it ignores the remainder of the line. It is good programming practice to fully document programs with comments. Comments in IDL do not slow down code execution or add noticeable size to IDL files.

A comment can exist on a line by itself, or can follow another IDL statement, as shown below:

; This is a comment 
COUNT = 5    ; Set the variable COUNT equal to 5. 

Toggle Comments

The Toggle Comments command affects all lines in the current selection. To toggle comments on, select a line or block of lines in the IDL Editor and select Source → Toggle Comment or click the Toggle Comment icon ed_commenticon.gif. Repeating this step turns the comment off.

Tip
Ctrl+; is the keyboard shortcut for Toggle Comments.

Manipulating Lines

You can easily move lines up or down, copy lines, or insert lines. Select a line or block of lines and do the following:

Previewing Changes with Quick Diff

You can see color-coded changes while you are typing by turning on the Quick Diff feature. In IDL Editor, Quick Diff is turned on by default. You can turn it on or off in one of the following ways:

The colors show additions, deletions, and changes compared to the contents of the file on disk. The following example shows two lines that have been changed:

ed_quickdiff.jpg

To see the original content of a changed line, hold the cursor over the left margin and a pop-up window shows the original content, as in the example below:

ed_quickdiff2.gif