Tutorial: Other Editor Features

Index of All Documentation » Wing Pro Tutorial »

There are a number of other editor features that are worth knowing about:


You can navigate quickly to a numbered source line with Goto Line in the Edit menu, or with the key binding displayed there. Type the line number and then press Enter to complete the action.

In Wing Pro and Wing Personal, line numbers can be shown in the editor with the Show Line Numbers item in the Edit menu.

Multiple Selections

In Wing Pro and Wing Personal, multiple selections can be made on the editor with the Edit > Multiple Selections menu items and multi-select Multiple Selections in the toolbar.

This provides a quick way to select several identical occurrences of text either sequentially, or within a particular file, class, function, or block:


Once there are multiple selections, edits made will be applied to all the selections concurrently.

Multiple selections may also be made by pressing Ctrl+Alt (or Command+Option on the Mac) while making a selection with the mouse.

Selection Mode and Structural Code Selection

Wing supports character, line, and block mode selection from Selection Mode in the Edit menu, and the key bindings shown there.

In Python code, the Select sub-menu in the Edit menu can be used to easily select and traverse logical blocks of code. The Select More and Select Less operations are particularly useful when preparing to type over or copy/paste ranges of text.

Try these out now on urllib in ReadPythonNews in example1.py. Each repeated press of Ctrl-Up will select more code in logical units. Press Ctrl-Down to select less code.

The other operations in the Select sub-menu can be used for selecting and moving forward or backward over whole statements, blocks, or scopes.

See Selecting Text for details.

Line Editing

In Wing Pro and Wing Personal, lines can quickly be inserted, deleted, duplicated, swapped, or moved up or down with the operations in the Line Editing sub-menu of the Source menu.

If your keyboard personality does not support them, then you can add your own key bindings with the User Interface > Keyboard > Custom Key Bindings preference. The command names are: new-line-before, new-line-after, duplicate-line-above, duplicate-line, move-line-up, move-line-down, delete-line, and swap-lines.

Code Snippets

In Wing Pro, the Snippets tool in the Tools menu can be used to define and use code snippets for commonly repeated motifs, such as class or def skeletons or documentation templates.

You may already have noticed that these appear in Wing's auto-completer. Try this now by typing def into the top level of a file in the editor. Then select the def (snippet) completion choice. Wing will place the snippet into the editor and enter into a data entry mode similar to the mode used for entering arguments when the Auto-Enter Invocation Arg auto-editing operation is enabled. Type any text you want in each field within the snippet and press Tab to move between the fields. Data-entry mode will end at the last tab stop or if you move out of the snippet body.

Now try it again with class and then inside the scope of the class use the def snippet again. Notice that the form of snippet in this context differs from the one used at the top level; it includes self. Like-named snippets can be defined in this way for the following contexts: module, class, function, method, attribute (after a period), comment, and string.

See Code Snippets for details.

Block Commenting

Lines of code can be commented out or un-commented quickly from the Source menu or, in Wing Pro, by pressing the # key while several lines of Python code are selected . In Python code, the Editor > Block Commenting Style preference controls the type of commenting that is used. The default is to use indented single # characters since this works better with some of Wing's other features.

Brace Matching

Wing highlights brace matches as you type, unless this is disabled from the Editor > Brace Matching > Brace Highlighting preference. The Match Braces item in the Source menu causes Wing to select all the code that is contained in the nearest matching braces, as found from the current insertion point on the editor. Repeated invocations of the command will traverse outward or forward in the file.

Text Reformatting

Code can be re-wrapped to the column configured in the preference Editor > Line Wrapping > Reformatting Wrap Column with the Rewrap Text item in the Source menu. This will limit wrapping to a single logical line of code, so it can be used to reformat function or method arguments or long list or tuple without altering surrounding code.


In Wing Pro, you can define and jump to marked locations in the editor with the bookmarking commands in the Source menu, the editor's right-click context menu, and the bookmark toolbar group.

In Python files, these bookmarks are defined relative to the named scope in the file so they move around with the scope as the file is edited outside of Wing. Bookmarks can be categorized and managed in the Bookmarks tool in the Tools menu.

See Bookmarks for details.