Wing Tips: Multiple Selections in Wing Python IDE
In this issue of Wing Tips we look at how to use multiple concurrent selections in Wing's editor. These can be used to replace all occurrences of some text or to apply the same edits to any number of selections, for example surround them all with quotes or remove common surrounding characters. Multiple selections can be created from the keyboard, from the mouse, or by using commands that select all occurrences of some text found within a selected code.
Creating Multiple Selections
The most common way to make multiple selections is to select a range of text in Wing's editor and then add other occurrences of the same text with Add Selection for Next Occurrence in the Edit > Multiple Selections menu. The default key binding for this is Ctrl-D, or Command-D on macOS, and Ctrl-> in the emacs keyboard personality.
Another way to add selections is to click on the multi-selection toolbar item . This menu includes items to select all occurrences in a file, class, function/method, or block of code:
Editing Selections
Once the selections are made your edits will be applied to all of them in the same way, as in the following example which replaces all occurrences of the word "stocks" with "trades":
Edits applied to all selections may include cursor movement, pasting, and other editing actions. For example selecting a number of commas, pressing the right arrow key, and then Space adds a space after all the commas:
Multi-Selecting with the Mouse
Multiple selections can also be made by clicking or double-clicking the mouse while holding Ctrl-Alt (or Option-Command on macOS). This allows selecting ranges that don't necessarily contain the same text:
Omitting Selections
By default, Wing displays a floating window that enumerates the selection made. You can omit selections from here by moving the mouse over an item and clicking on the red X icon that appears over it. Edits made subsequently are applied only to the selections that remain:
Configuration Options
Whether occurrences used for multi-selection match any text or only whole words, and whether they are case sensitive, may be controlled from the Edit > Multiple Selections menu or the multi-selection toolbar item .
The multi-selection popup window can also be entirely enabled or disabled from here, with the Configure Selections Window item.
That's it for now! We'll be back next week with more Wing Tips for Wing Python IDE.
Share this article: