Wing Tips: Auto Completion in Wing Pro

Jun 08, 2023


In this issue of Wing Tips we introduce Wing Pro's auto-completer, which can be used to find and more quickly enter symbols, imports, and snippets into Python code.

By default, Wing shows the auto-completer as you type in the editor, populating the completer with whatever code symbols and snippets are relevant to the particular context you are working in. The arrow keys can be used to move up and down the completion list and a completion is selected by pressing Tab or other completion key configured with the Editor > Auto-completion > Completion Keys preference in Wing. The same preferences group lets you specify whether to show the completer immediately or only after a certain number of characters or elapsed time, how to place the completion, and various other options.

Here is what the completer looks like in action:

Auto-Completion in Wing Pro

Shown above: Using the auto-completer to enter new Python code in Wing Pro.

Notice that the auto-completer contains two columns of icons like package inherited and function that indicate the origin and type of the symbol. These are described in detail in Auto-completion Icons.

Auto-Import

In Wing 9.1 and later the auto-completer also contains suggestions for modules you may want to import for the code that you are writing. When these completions are selected, Wing enters the symbol for the selected import at the current position in the editor and also adds the necessary import statement at the top of your file:

Auto-importing in Wing Pro

Shown above: Using the auto-completer to enter code and new import statements simultaneously.

The Editor > Auto-completion > Python Auto-Imports preference controls whether to always show auto-imports, show them only on request, or to hide them entirely from the completer. See also the Imports tool.

Snippets

The completer also offers code snippets appropriate for the current context. These are indicated with the snippet scissors icon. The default set of snippets that come with Wing Pro may be viewed and altered in the Snippets tool in the Tools menu.

Here is an example of entering snippets with the auto-completer, using the Tab key to move between and fill out fields in the snippets:

Auto-completing snippets in Wing Pro

Shown above: Using the auto-completer to enter code snippets for a class, a method, and a nested definition, showing how snippets can take different forms depending on their context in the code.

See the Code Snippets documentation for more information.



That's it for now! We'll be back next week with more Wing Tips for Wing Python IDE.



Share this article: