Wing IDE Reference Manual
   
Wing IDE Reference Manual

Version 1.1.10


next up previous contents
Next: 5. Source Code Browser Up: Reference Manual Wing IDE Previous: 3. Project Manager


Subsections

4. Source Code Editor

Wing IDE's source code editor is designed to make it easier to adopt the IDE even if you are used to using other editors. If you are frustrated by the editor or key combinations, please review information in this chapter and in the Customization chapter; you have a fair amount of control over how the editor acts.


   For those in a rush, key things to know about the editor are:
  • The editor has personalities, including one similar to basic editors on Windows and another similar to emacs.
  • Key mappings are configurable.
  • The editor supports a wide variety of file types for syntax colorization.
  • Auto-completion is supported for Python source (but can be turned off if desired).


4.1 Using multi-view window mode

When preference gui.one-view-per-window is set to false (the default value), Wing will place newly opened or created editor views into the most recently used editor window.

While working in this mode, you can use the Windows menu to switch to hidden views, or to views shown in other windows. Note that the Windows menu is organized by window type, starting with manager windows like the debugger and project manager, then dialog windows if any are open, then visible source views, and finally a list of all other views that are not currently visible on the display. When you switch to a non-visible view, it is brought to front within its window and then its window is brought to front in the display.

Whenever a newly opened file is already open in some window, Wing will show the existing view into the file by bringing its window to front, instead of opening another view into the file. Also, in multi-view mode, closing a view will not close its window unless it is the last view in that window.

You can use the New area of the File menu to create new source documents or to open additional source windows, each of which may contain any number of source views:

Multiple views into the same file can be created from the File menu with the New Cloned Window command. Wing tracks edits in all views into a source file, allowing you to edit two parts of a file at the same time without scrolling back and forth.

When using multiple views into the same source file, you will only be prompted to save changes when the last open view for a given source file is closed.

4.2 Using single-view mode

When multi-view mode is turned off, Wing will open one window for each source document. The Windows menu will still list all open views but will not distinguish between visible and hidden views, since all views will be visible in a window.

Single-view mode offers only the following two file and window related commands in the File menu's New area:

4.3 Syntax Colorization

The editor will attempt to colorize documents according to their MIME type, which is determined by the file extension, or content. For example, any file ending in '.py' will be colorized as a Python source code document. Any file whose MIME type cannot be determined will display all text in black normal font by default.

If you have a file that is not being recognized, you can use the Source Menu's Syntax Highlighting section to alter the way the file is being displayed. Your selections from this menu are stored in your project file, so changes made here are permanent in the context of that project.

If you have many files with an unrecognized extension, you can alter the main.extra-mime-types preference to add your extension. See section 2.2.7 for details on setting this value. Note however that adding a new MIME type not already in the list above will not work without more extensive modifications to the IDE source code.

4.3.1 Supported file types

The editor supports the following file types for syntax colorization:

Mime Type Description Allowable Extensions
text/x-python Python Source py, cgi, or files starting with a #! specifier
    that invokes Python
text/html HTML Source html, htm, asp, shtml
text/x-c-source C Language Source c, h
text/x-cpp-source C++ Source cc, cpp, cxx, hh, hpp, hxx
text/x-java-source Java Source java
text/x-vb-source Visual Basic Source cls, bas, ctl, frm, vbs
text/x-dos-batch DOS Batch File bat
text/x-properties DOS Style INI File properties, ini, inf, reg
text/x-makefile Makefile makefile, mak, and any file named
    'makefile' or 'Makefile'
text/x-errorlist Compilation Error List err
text/x-sql SQL Source sql
text/x-plsql PL SQL Source spec, body, sps, spb, sf, sp
text/x-xml XML Source xml, xul, glade
application/x-tex LaTeX Source tex, sty
text/x-lua-source Lua Source lua
text/x-idl CORBA IDL idl, odl
text/x-javascript Javascript js
text/x-rc DOS RC File rc, rc2, dlg
text/x-php-source PHP Source php, php3, phtml, inc
text/x-perl Perl Source pl, pm, pod
text/x-diff Diff/CDiff or Patch File diff, patch
text/x-conf Conf Files conf
text/x-pascal Pascal Source pas, inc
text/x-ave Ave document ave
text/x-ada Ada Source abs, adb
text/x-ave Eiffel Source e
text/x-ave Lisp Source lsp, lisp
text/x-ave Ruby Source rb
text/x-ave Bash File sh, bsh
text/plain Plain Text (no highlighting) all others



4.3.2 Colorization Options

Although the specific colors and other values associated with syntax colorization are not yet user-configurable, you can alter the text and font that is used throughout a file or files. To do this, select the Set Display Font/Size item from the Source menu and make your selection from the dialog's popup menus.

You can make changes for individual files on a per-file basis, or for all files that you open. Either way, your selection is saved in the project file for subsequent work sessions.

Changes are shown immediately on your source, but are only permanent after the font/size selection dialog is closed if you use the Apply and Exit button. Otherwise, values are restored to those in use before the selector dialog was displayed.

4.4 Navigating your Source


   When you right-click on the surface of the editor, all editor windows will bring up a popup menu with commonly used commands such as Copy, Paste, Undo, and Redo. When the file is a Python file, this menu also includes a construct-by-construct breakdown of the source file.

In order to navigate your source, right-click on the editor surface and select one of the constructs in the popup menu. This will scroll the source code to the position at which that construct is defined and select its point of definition.

Python language constructs in the popup menu are colorized as follows:

The editor popup menu is also available from the popup button at the lower right corner of the editor window.

You can also use the Goto Definition menu item in the right-click popup menu to click on a construct in your source and zoom to its point of definition. Alternatively, place the cursor or selection on a symbol and use the Goto Selected Symbol Defn item in the Source menu, or its keyboard equivalent.

4.5 Structural Folding

The editor supports optional structural folding for Python, C, C++, Java, Javascript, HTML, files, Eiffel, Lisp, and Ruby files. This allows you to visually collapse logical hierarchical sections of your code as you are working in other parts of the file.

You can turn Structural Folding on and off from the Code Folding section of the Project menu. This setting is remembered with your project. You can also enable or disable folding by default for newly created projects by setting the edit.enable-folding preference. The preference edit.fold-line-mode can be used to determine whether or not a horizontal line is drawn at fold points, whether it is drawn above or below the fold point, and whether it is shown when the fold point is collapsed or expanded. See section 4.17 for allowed values for this preference.

Once folding is turned on, an additional margin appears to the left of source files, where fold points are by default indicated with blue minus signs. Left mouse click on one of these signs to collapse that fold point. Once collapsed, the fold point is by default indicated by a blue plus sign. Clicking again will re-expand it. Preference edit.fold-indicator-style can be used to change the style of indicators used at fold points to arrows, or tree style views. Details for changing this preference are in section 4.17

You can also hold down the following key modifiers while clicking to modify the folding behavior:

Fold commands are also available in the Structural Folding section of the Source menu and by the indicated key equivalents:

Since only a subset of file types supported by Wing IDE also support folding, the preference edit.fold-mime-types is used to turn on folding by mime type for only specific file types. This should generally remain unchanged from the defaults but can be used to turn off folding for specific file types, such as only C or only Python source, while keeping folding on for other files.

4.6 Brace Matching

Wing will highlight matching braces in green when the cursor is adjacent to a brace. Mismatched braces are highlighted in red.

You can also cause Wing to select the entire contents of the innermost brace pair from the current cursor position with the Match Braces item in the Source menu.

Parenthesis, square brackets, and curly braces are matched in all files. Angle brackets (< and >) are matched also in HTML and XML files.


4.7 Indentation

The editor provides a range of features for managing indentation in source code. The following preferences affect how the indentation features behave in newly created source files:

  1. The preference edit.tab-size defines the default size of each tab character, in spaces.
  2. The preference edit.indent-size defines the default size of each level of indent, in spaces.
  3. The preference edit.indent-style defines the default indentation style, one of 'spaces-only', 'tabs-only', or 'mixed'. Mixed indentation replaces each tab-size spaces with one tab character.
  4. The preference edit.auto-indent controls whether or not each new line is automatically indented.
  5. The preference edit.show-indent-guides controls whether or not to show indentation guides as light vertical lines. This value can be overridden on a file by file basis from the Indentation section of the Source menu.

When an existing file is opened, it is scanned to determine what type of indentation that is used in that file. If the file contains some indentation, this may override the tab size, indent size, and indent style values given in preferences and the file is subsequently indented in a way that matches its existing content rather than with your configured defaults. If mixed forms of indentation are found, the most common form is used.

For Python files, the detected form of indentation cannot be overridden and Wing will always match new indentation to existing indentation. Mixing indentation styles in Python is dangerous because indentation has syntactic importance in this language.

For non-Python files, you can change indentation style on the fly using the Use Spaces Only, Use Tabs Only, and Use Mixed Tabs and Spaces items in the Indentation portion of the Source menu. This allows creating files that intentionally mix indentation forms in different parts of the file. To ask Wing to return to the form of indentation it determines as most prominent in the file, select the Use Style Matching File item in the Indentation section of the Source menu.

You may also convert the entire file between different forms of indentation using the Indentation Manager available from the Indentation portion of the Source menu. This is described in section 4.7.5 below.


   Tab size is automatically forced to 8 characters for all Python source files that contain some spaces in indentation. This is done because the Python interpreter defines tabs as 8 characters in size in this case. This version of Wing does not recognize vi style tab size comments, but it does apply the edit.tab-size preference when a file contains only tabs in indentation, or if it is a non-Python file.

4.7.1 Auto-Indent

The IDE ships with auto-indent turned on. This causes leading white space to be added to each newly created line, as return or enter are pressed. Enough white space is inserted to match the indentation level of the previous line, possibly adding a level of indentation if this is indicated by context in the source (such as if or while).

Note that if preference edit.auto-indent is set to false, auto-indent does not occur until the tab key is pressed.

4.7.2 The Tab Key

By default, the tab key acts like auto-indent: the leading white space of the current line is adjusted to achieve a reasonable indentation level for that line.

Existing leading white space is replaced with white space containing either spaces only or tabs and spaces, as determined by the method described above. This behavior may also decrease indent level of a line, if it is deemed to be indented too far according to its context.

If multiple lines are selected at the time that the tab key is pushed, all those lines will be indented or outdented as a unit according to the amount of change necessary for the first line in the selected unit. This is very useful when moving around blocks of code.

To insert a real tab character regardless of the indentation mode or the position of the cursor on a line, type Ctrl-Tab or Ctrl-T.

4.7.3 Checking Indentation

Wing analyses existing indentation whenever it opens a Python source file, and will indicate a potentially problematic mix of indentation styles, allowing you to attempt to repair the file. Although files are checked each time they are opened, Wing will display the indentation warning dialog only once per file and will not ask twice about the same file if you do not repair it (this information is stored in the project file). Files can be inspected more closely or repaired at any time using the Indentation Manager described in section 4.7.5.

Wing also indicates suspiciously mismatch indentation on the source code by underlining the indent area of the relevant lines in blue.


   In general, mixing tab/space and space-only indentation in the same file can be confusing, especially if files are viewed with different editors and by different developers. We recommend using spaces only or tabs only as the best alternatives. To convert existing code containing a mix of tabs and spaces, use the Indentation Manager.

4.7.4 Changing Block Indentation

Wing provides Indent and Outdent commands in the Indentation portion of the Source menu, to support increasing or decreasing the level of indentation for selected blocks of text. All lines that are included in the current text selection are moved, even if the entire line isn't selected.

Indentation placed by these commands will contain either only spaces, only tabs, or a mixture of tabs and spaces, as determined by the method described at the start of section 4.7 above.


4.7.5 Indentation Manager

The indentation manager can be used to inspect and change indentation style in source files. To display the indentation manager for a given file, use the Indentation Manager item in the Indentation group of the Source menu.

The indentation manager has two parts to it: (1) The indentation report, and (2) the indentation converter.

A report on the nature of existing indentation found in your source file is given above the horizontal divider. This includes the number of spaces-only, tabs-only, and mixed tabs-and-space indents found, information about whether indentation in the file may be problematic to the Python interpreter (if it's a Python source file), and the tab and indent size computed for that file. The manager also provides information about where the computed tab and indent size value come from (for example, an empty file results in use of the defaults configured in preferences).

Conversion options for your file are given below the horizontal divider. The three tabs are used to select the type of conversion desired, and each tab contains information about the availability and action of that conversion, and a button to do the conversion. Most of these conversions have no parameters that can be altered by the user. Only in the case of conversion from tabs-only to spaces-only indentation styles, the tab size value shown in the indentation report is made editable, so that the configured default can be overridden.

Once conversion is complete, the indentation manager updates to display the new status of the file, and action of any subsequent conversions. Because the indentation manager updates each time its source file is edited, typing in a source window may slow noticeably when its indentation manager window is visible.

4.8 Auto-completion

While typing in Python source code, Wing will display an autocompletion popup that can be used to reduce your typing burden. To use it, type until the correct symbol is hilighted in the list and then press the tab key. Wing will fill in the remaining characters for the source symbol, correcting any spelling errors you might have made in the name.

If you wish to select a name without typing enough of the name to make your selection unique in the autocompleter, you can use the keyboard up and down arrow keys or mouse to scroll up and down in the popup list. Pressing tab or double clicking on a list item will complete that symbol in your source.

To cancel out of the autocompletion popup, press the Esc key or ctrl-g. The autocompleter will also disappear when you exit the source symbol (for example, by pushing space or any other character that can't be contained in a source symbol), if you click elsewhere on the surface of the source code, or if you issue other keyboard bound commands that are not accepted by the autocompleter (for example, save through keyboard equivalent or right/left arrow keys).


   Auto-completion covers most but not all possible scenarios at this time. See section 4.16 for more information on current capabilities.

Until Python includes support for data typing, one way to get a lot more mileage out of the auto-completion facility is to use statements that assert variables as belonging to a specific class. An example is assert isinstance(obj, CMyClass). The code analysis facility will pick up on these and present you with the correct auto-completion values when you type obj. subsequently. An added bonus is that your code will catch errors in expected variable types in more cases.


4.9 Auto-save

The source code editor auto-saves files to disk every few seconds. The autosave files are placed in a subdirectory of your Wing user directory (~/.wingide/autosave on Linux/Unix or WINGHOME\profiles\[username]\autosave on Windows). If Wing ever crashes or is killed from the outside, you can use these files to recover any unsaved changes. It is usually safe to copy the autosave files to overwrite the older unsaved files, but you may want to do a comparison first to verify that the autosave file is what you want.

4.10 Notes on Copy/Paste

There are a number of ways to copy and paste text in the editor:

It's important to note which actions use the system-wide clipboard, which use the emacs kill buffer (emacs mode only), and which use the X windows selection (X Windows only). Otherwise, these commands are interchangeable in their effects.


4.11 Auto-reload of Externally Changed Files

Wing's editor detects when files have been changed outside of the IDE and can reload files automatically, or after prompting you for permission. This is useful when working with an external editor, or when using code generation tools that rewrite files.

Wing's default behavior is to automatically reload externally changed files that you have not yet been changed within Wing's source editor, and to prompt to reload files that have also been changed in the IDE.

You can change these behaviors by setting the value of the cache.unchanged-reload-policy and changed-reload-policy preferences, as described at the end of section 4.17.

On Windows, Wing uses the change signal capability of the OS to detect changes so notification or reload is usually instant. On Linux/Unix, Wing polls the disk by default every 3 seconds; this frequency can be changed with the cache-reload-freq preference.


4.12 Normal Editor Personality


   Wing's source code editor can run with different personalities, either as a normal basic text editor, or as an emacs-like editor that is readily controlled with keyboard-driven commands.

The default personality for Wing is 'normal'. This uses only the graphical user interface for interacting with the editor and doesn't make use of any complex keyboard-driven command interaction.

The editor runs in normal mode when the edit.personality preference is set to normal. See section 2.1 of the Customization chapter for more information on how to alter your preferences.

In normal mode, the editor provides the following keyboard equivalents, which are defined in the default normal mode key mapping in file WINGHOME/keymap.normal.

4.12.1 Cursor Movement




Key Combination Command Description
shift + arrow keys previous-line-extend, next-line-extend, backward-char-extend, forward-char-extend Move cursor in indicated direction, extending the current text selection.
shift-page-up and shift-page-down forward-page-extend, backward-page-extend Move forward or backward a page, extending the current text selection.
ctrl-right-arrow and ctrl-left-arrow backward-word, forward-word Move cursor backward or forward a word. These can be combined with shift key for extension of selection.
home and end beginning-of-line, end-of-line Move cursor to beginning or end of line. Repeated home on an indented line will alternate between the absolute beginning and end of indentation. These can be combined with shift key for extension of selection.
ctrl-home and ctrl-end start-of-document, end-of-document Move cursor to beginning or end of document. These can be combined with the shift key for extension of selection.

4.12.2 Indentation

Key Combination Command Description
tab indent-to-match Indent the current line or selection to match the preceding non-blank line, adding or subtracting indentation as appropriate. See section 4.7 above for more information on indentation behavior.
ctrl-tab forward-tab Insert a forward tab character.
shift-tab backward-tab Insert a backward tab character.
ctrl-> indent-region Increase indent of the current line or selected region by one level of indentation.
ctrl-< outdent-region Decrease indent of the current line or selected region by one level of indentation.

4.12.3 Commenting and Justification

Key Combination Command Description
ctrl-/ comment-out-region Comment out the selected region of code. This operates on whole lines, extending the current selection as necessary.
ctrl-? uncomment-out-region Undo commenting out the selected region of code. This operates on whole lines, extending the current selection as necessary.
ctrl-j fill-paragraph Rejustify the paragraph of text at the current selection's starting position. This operates on whole lines, and is most useful for formatting comments, long strings, or documentation. Set the column at which to wrap with the edit.text-wrap-column preference.

4.12.4 Insertion and Deletion

Key Combination Command Description
delete forward-delete-char Delete the character in front of the cursor, or the current selection if not empty.
ctrl-delete forward-delete-word Delete the word in front of the cursor.
insert toggle-overtype Alternate between overtype and insert mode.
ctrl-backspace or alt-backspace or alt-delete backward-delete-word Delete the word behind the cursor.

4.12.5 Undo and Clipboard

Key Combination Command Description
ctrl-z undo Undo most recent edit.
ctrl-y redo Redo most recent undone edit.
ctrl-x cut Cut the current selection to clipboard.
ctrl-c copy Copy the current selection to clipboard.
ctrl-v paste Paste from clipboard, replacing the current selection.
ctrl-a select-all Select the entire document.

4.12.6 File and Window Control

Key Combination Command Description
ctrl-n new-file Creates a new source view with an untitled new file name.
ctrl-o open-gui Open a new document from disk.
ctrl-s save Save the current document to disk.
shift-alt-d delete-window Close the current view, and the window if it's the last view in the window.
shift-alt-w clone-window Create a new editor window containing all the same source views as the current window.
shift-alt-e move-editor-to-new-window Move the current source editor view to a new window, removing it from its current window. This is only available in multi-view mode and when there is more than one view in the current window.
ctrl-w kill-buffer Close the current file, prompting to save if necessary. Only closes the current window when the last view in the window is closed.

4.12.7 Search and Replace

Key Combination Command Description
ctrl-alt-9 search-manager Display the search manager dialog.
ctrl-f search-forward Search forward in current document, using most recent search string. If there is no search string, the search manager is brought to front.
ctrl-b search-backward Search backward in current document, using most recent search string. If there is no search string, the search manager is brought to front.
ctrl-f3 search-sel-forward Search forward in current document, using the current selection or nearest word as the search string. Search for the next match is immediately initiated.
ctrl-shift-f3 search-sel-backward Search backward in current document, using the current selection or nearest word as the search string. Search for the next match is immediately initiated.
ctrl-r query-replace Initiate search/replace in current document.
ctrl-i replace-and-search Replace given occurence and search again.
ctrl-l goto-line Jump to a selected line number.

4.12.8 Macros

Key Combination Command Description
ctrl-( start-kbd-macro Start recording a macro (will contain any keystrokes and commands issued to the editor).
ctrl-) stop-kbd-macro Stop recording current macro and store it.
ctrl-m execute-kbd-macro Execute most recently defined keyboard macro relative to current cursor position.

4.12.9 Other

Key Combination Command Description
ctrl-e or ctrl-] brace-match Select the region between the nearest braces or defining the inner most code block reached from current cursor position.
ctrl-g goto-selected-symbol-defn Jump to point of definition of the symbol at or near the cursor or selection.
ctrl-right-click goto-clicked-symbol-defn Jump to point of definition of the symbol most recently clicked on.
ctrl + keypad plus and minus keys zoom-in, zoom-out Zoom text in and out by increasing and decreasing font sizes.
ctrl-p print-view Print the current editor view.

See the section 2.2.3 for information on how to alter or replace this mapping.


4.13 Emacs Emulation

When preference edit.personality is set to 'emacs', the editor will run in a mode that emulates many emacs behaviors. In this mode, key strokes can be used to control most of the editor's functionality, using a textual interaction 'mini-buffer' at the bottom of the editor window where the current line number and other informational messages are normally displayed.

When in emacs mode, the editor supports the following key combinations for access to commands.

4.13.1 Cursor Movement




Key Combination Command Description
shift + arrow keys previous-line-extend, next-line-extend, backward-char-extend, forward-char-extend Move cursor in indicated direction, extending the current text selection.
ctrl + space bar set-mark-command Set selection start to current position and start automatically selecting from that point as the cursor is moved with arrow keys, page up/down, search commands, or in other ways.
ctrl-g stop-mark-command Cancel selecting a range, as initiated by set-mark-command, and set the cursor position to the end of the range.
home and end or ctrl-a and ctrl-e beginning-of-line, end-of-line Move cursor to beginning or end of line. Repeated home on an indented line will alternate between the absolute beginning and end of indentation. These can be combined with shift key for extension of selection.
ctrl-n and ctrl-p next-line and previous-line Move cursor to next or previous line.
ctrl-b and ctrl-f backward-char and forward-char Move cursor backward or forward one character.
ctrl-v and alt-v forward-page and backward-page Move forward or backward one page.
ctrl-home and ctrl-end start-of-document, end-of-document Move cursor to beginning or end of document. These can be combined with the shift key for extension of selection.
ctrl-l center-cursor Center the cursor on screen.

4.13.2 Indentation

Key Combination Command Description
tab indent-to-match Indent the current line or selection to match the preceding non-blank line, adding or subtracting indentation as appropriate. See section 4.7 for more information on indentation behavior.
ctrl-c > indent-region Increase indentation of the currently selected range of lines (or current line when selection is empty) by one indentation level.
ctrl-c < outdent-region Reduce indentation of the selected range of lines (or current line when selection is empty) by one indentation level.
ctrl-tab forward-tab Insert a forward tab character.
shift-tab backward-tab Insert a backward tab character.

4.13.3 Commenting and Justification

Key Combination Command Description
ctrl-c c or ctrl-c # comment-out-region Comment out the selected region of code. This operates on whole lines, extending the current selection as necessary.
ctrl-c u uncomment-out-region Undo commenting out the selected region of code. This operates on whole lines, extending the current selection as necessary.
escape q or ctrl-j fill-paragraph Rejustify the paragraph of text at the current selection's starting position. This operates on whole lines, and is most useful for formatting comments, long strings, or documentation. Set the column at which to wrap with the edit.text-wrap-column preference.

4.13.4 Insertion and Deletion

Key Combination Command Description
ctrl-d forward-delete-char Delete the character in front of the cursor, or the current selection if not empty.
ctrl-delete or alt-d forward-delete-word Delete the word in front of the cursor.
delete clear Delete current selection, if any.
insert toggle-overtype Alternate between overtype and insert mode.
ctrl-backspace or alt-backspace or alt-delete backward-delete-word Delete the word behind the cursor.

4.13.5 Undo and Clipboard

Key Combination Command Description
ctrl-/ or ctrl-x u undo Undo the most recent edit action.
ctrl-w or shift-delete cut Cut the current selection to system-wide clipboard.
alt-w or ctrl-insert copy Copy the current selection to system-wide clipboard.
ctrl-y or shift-insert paste Paste from system-wide clipboard, replacing any current selection.
ctrl-k kill-line Remove the current line after the cursor point and place it into the kill buffer. Groups of lines deleted this way can be pasted subsequently with yank-line (ctrl-y). This is kept seperate from the system-wide clipboard and (on X windows) from the current selection. This command removes the newline only if there is no visible character on the line after the cursor.
ctrl-y yank-line Paste the current contents of the kill buffer, created with one or more adjacent kill-line commands, replacing any current selection. If the kill buffer is empty, the contents of the system-wide clipboard is pasted instead.

4.13.6 File and Window Control

Key Combination Command Description
ctrl-x ctrl-c quit Quit the application, first prompting to save any unsaved documents.
ctrl-x ctrl-s save Save current file to disk.
ctrl-x k kill-buffer Close the current file, prompting to save if necessary. Only closes the current window when the last view in the window is closed.
ctrl-x ctrl-f open Open a file from disk. Enter the filename at prompt, optionally using the tab key to auto-complete the current entry. Two tabs in a row will display a list of possible matches; continue typing or click on a match as desired. You can also use the up/down arrow keys to scroll through recently-opened files. Hitting enter opens the selected file. Exit without opening with ctrl-g or esc.
ctrl-x i insert-file Insert a file at current cursor position. Interaction is the same as for the open command.
ctrl-x 5 2 clone-window Create a new editor window containing all the same source views as the current window.
ctrl-x 5 3 move-editor-to-new-window Create a new editor window containing the current source view, moving the view out of its current window. This is only available in multi view mode and only when there is more than one view in the current window.
ctrl-x b switch-document Switch to another document. Hit enter to select the specified default, type file name fragments (tab and double-tab can be used for completion and viewing list of matches), or use the up/down arrow keys to scroll through a list of options. Enter accepts and switches; escape or ctrl-g aborts.
ctrl-alt-L previous-document Switch to most recent previous source document
ctrl-x 5 0 delete-window Close the current editor window.


4.13.7 Search and Replace

Key Combination Command Description
ctrl-s search-forward Initiate interactive incremental forward search. The search is case sensitive if you type any capital letters; otherwise case-insensitive. Exit search by using arrow keys or other commands, or abort (returning to original position) with ctrl-g or esc.
ctrl-r search-backward Initiate interactive incremental backward search. Acts like forward search, only proceeds backward in source.
ctrl-c s search-sel-forward Initiate interactive incremental forward search, using the current selection or nearest word as the search string and immediately searching for the next match.
ctrl-c r search-sel-backward Initiate interactive incremental backward search, using the current selection or nearest word as the search string and immediately searching for the next match.
alt-percent or escape percent query-replace Initiate interactive query/replace. First type search string, then replace string and respond to prompts with 'y' and 'n'. You may use the tab key to auto-complete values you type into the search and replace strings. End the session with ctrl-g or escape.
alt-g or alt-l or escape g goto-line Go to a specific line; enter the line number at prompt.

4.13.8 Macros

Key Combination Command Description
ctrl-x ( start-kbd-macro Start recording a macro (will contain any keystrokes and commands issued to the editor).
ctrl-x ) stop-kbd-macro Stop recording current macro and store it.
ctrl-x m execute-kbd-macro Execute most recently defined keyboard macro relative to current cursor position.
escape + numbers initiate-repeat-* Start entering a repeat value which will cause the immediately following command or keystroke to be executed the specified number of times. Use esc or ctrl-g to abort. This is particularly useful to execute a keyboard macro multiple times in a row.

4.13.9 Other

Key Combination Command Description
ctrl-m brace-match Select the region between the nearest braces or defining the inner most code block reached from current cursor position.
ctrl-c g goto-selected-symbol-defn Jump to point of definition of the symbol at or near the cursor or selection.
ctrl-right-click goto-clicked-symbol-defn Jump to point of definition of the symbol most recently clicked on.
ctrl + keypad plus and minus keys zoom-in, zoom-out Zoom text in and out by increasing and decreasing font sizes.
alt-x or escape x command-by-name Enter a command by name for execution. Use the tab key for auto-completion or double-tab to see a list of possible matches. Up/down arrow keys also work for scrolling through recent commands. Hit enter to execute the command or esc or ctrl-g to abort.

Many of these commands are also available through menu items. See section 2.2.3 for information on how to alter or replace this mapping.

4.14 Search/Replace

All editor modes include a graphical search/replace manager, which can be brought up with the Search Manager item in the Edit menu. Commands in this window will apply to the current (most recently at front) source view.

To use this manager, enter search and optionally replace text, set search options, and control the search/replace process with the provided buttons.

Replace actions can always be undone, including Replace All.

Emacs mode additionally provides ctrl-s and ctrl-r incremental search, and query-replace facilities, as described in section 4.13.7 above.

4.15 Keyboard Macros


   The Edit menu contains items for starting and completing definition of a keyboard or command sequence macro, and for executing the most recently defined macro. Once macro recording is started, any keystroke or editor command is recorded as part of that macro. Most commands listed in sections 4.12 and 4.13 above may be included in macros, as well as all character insertions and deletions.

The keyboard macro feature is currently most useful in emacs mode, where powerful cursor-relative macros can be built for repetitive reformatting tasks. This is done by combining incremental search with cursor movement and typing.

4.15.1 Example (in Emacs mode)

A common task when writing Python bindings for C/C++ libraries is copying lists of #define constants and converting them into Python variable assignments.

#define SC_MARK_CIRCLE 0
#define SC_MARK_ROUNDRECT 1
#define SC_MARK_ARROW 2
#define SC_MARK_SMALLRECT 3
#define SC_MARK_SHORTARROW 4
#define SC_MARK_EMPTY 5
#define SC_MARK_ARROWDOWN 6
#define SC_MARK_MINUS 7
#define SC_MARK_PLUS 8
       

In emacs mode, the above can be converted by positioning the cursor before the first #define, starting macro definition, and executing the following keystrokes:


escape 8 ctrl-d ctrl-s <space> <right arrow> = <space> ctrl-a <down arrow>

This deletes the 8 characters '#define ' (with trailing space) in front of the cursor, jumps to the space after the constant identifier, inserts '= ', and moves to the beginning of the next line. When this is complete, stop macro recording and type the following to convert the remaining lines:


escape 8 ctrl-x e

This will execute the macro eight times resulting in the following reformatted source (the first line was reformatted during the creation of the macro):

SC_MARK_CIRCLE = 0
SC_MARK_ROUNDRECT = 1
SC_MARK_ARROW = 2
SC_MARK_SMALLRECT = 3
SC_MARK_SHORTARROW = 4
SC_MARK_EMPTY = 5
SC_MARK_ARROWDOWN = 6
SC_MARK_MINUS = 7
SC_MARK_PLUS = 8
       

Combine this technique with ctrl-space (set-mark-command) and copy/paste to alter the order of constructs within a line. Be creative... and don't forget that undo can be used to fix problems caused by incorrect macros or bad cursor position before executing a macro.

Macros will terminate if any command within the macro fails (for example, if an incremental search fails). This can be used to prevent edits when a macro is executed in a location where it doesn't make sense.

4.15.2 Repetition


   In emacs mode, macros can be executed over and over again by using the escape + numbers key board interaction to set up a repetition count before executing the macro. For example, type 'escape 1 0 ctrl-x e' in emacs mode to execute a macro ten times in a row.


4.16 Source Code Analysis

Wing's auto-completer, source index menu, goto-definition capability, some of the source reformatting features, and the source code browser all rely on a central engine that reads and analyzes your source code in the background as you add files to your project or alter your code in the source code editor.

4.16.1 Python versions


   In analysing your source, Wing will use the Python interpreter and PYTHONPATH that you have specified in your debug properties. If you have indicated a main debug file for your project, the values from that file's per-file debug properties are used; otherwise the project-wide values are used. Whenever any of these values changes, Wing will completely re-analyze your source code from scratch.

You can view the Python interpreter and PYTHONPATH that are being used by the source code analysis engine, by selecting the Show Analysis Stats item in the Source menu. The values shown in the resulting dialog window are read-only but may be changed by pushing the Settings button. See section 6.3 for details on changing these values.

Be aware that if you use multiple versions of the Python interpreter or different PYTHONPATH values for different source files in your project, Wing will analyse all files in the project using the one interpreter version and PYTHONPATH it finds through the main debug file or project-wide debug properties settings. This may lead to incorrect or incomplete analysis of some source, so it is best to use only one version of Python with each Wing IDE project file.


4.16.2 Limitations

The following are known limitations affecting features based on source analysis:


   One way to inform the code analysis facility of the type of a variable is to add an isinstance call in your code. An example is assert isinstance(obj, CMyClass). The code analyzer will pick up on these and present more complete information for the asserted values. This assertion may have the side-effect of catching type errors at the time isinstance is called rather then when an invalid operation is attempted.

4.16.3 Disk Cache

The source code analyzer writes information about files it has recently examined under ~/.wingide/cache (on Linux/Unix) or WINGHOME\profiles\[username]\cache (on Windows).

Cache size may be controlled with the pysource.max-disk-cache-size preference. However, Wing does not perform well if the space available for the cache is smaller than the space needed for a single project's source analysis information. If you see excessive slowdowns, either increase the size of the cache or disable it entirely by setting its size to 0.

If the cache will be used by more than one computer, make sure the clocks of the two computers are synchronized. The caching mechanism uses time stamps, and may become confused if this is not done.

The analysis cache may be removed in its entirety with no ill effects (for example 'rm -rf ~/.wingide/cache' on Linux/Unix or remove WINGHOME\profiles\[username]\cache on Windows). It will be rebuilt as needed subsequently unless it has been disabled.


4.17 Preferences

The following preferences are defined for the editor:

The following additional preferences that control reloading of file caches are also relevant:

You need to quit and restart Wing before any changes in these preferences take effect.


next up previous contents
Next: 5. Source Code Browser Up: Reference Manual Wing IDE Previous: 3. Project Manager   Contents



2003-08-28