Wing IDE provides several different interfaces for searching your code. Which you use depends on your task.

Search Tool

The Search tool provides a familiar GUI-based search and replace tool for operating on the current editor. Key bindings for operations on this tool are given in the Search and Replace group in the Edit menu.

search.png

Searches may span the whole file or be constrained to the current selection, can be case sensitive or insensitive, and may optionally be constrained to matching only whole words.

By default, searching is incremental while you type your search string. To disable this, uncheck Incremental in the Options menu.

Replacing

When the Show Replace item in Options is activated, Wing will show an area for entering a replace string and add Replace and Replace All buttons to the Search tool:

search-replace.png

Try replacing example1.py with search string PrintAs and replace string OutputAs.

Select the first result match and then Replace repeatedly. One search match will be replaced at a time. Search will occur again after each replace automatically unless you turn off the Find After Replace option. Changes can be undone in the editor, one at a time. Do this now to avoid saving this replace operation.

Next, try Replace All instead. Wing will simply replace all occurrences in the file at the same time. When this is done, a single undo in the editor will cancel the entire replace operation.

Wildcard Searching

By default, Wing searches for straight text matches on the strings you type. Wildcard and regular expression searching are also available in the Options menu.

The easier one of these to learn is wildcard searching, which allows you to specify a search string that contains * to match anything, ? to match a single character, or ranges of characters specified within [ and ] to match any of the specified characters. This is the same syntax supported by the Python glob module and is described in more detail in the Wildcard Search Syntax manual page.

Try a wildcard search now by selecting Wild Card from the Options menu and making sure example1.py is your current editor. Set the search string to PrintAs*(. This should display match all occurrences of the string PrintAs, followed by zero or more characters, followed by (:

search-wildcard.png

Also try searching on PrintAs*[A-Z]( with the Case Sensitive search option turned on. This matches all strings starting with PrintAs followed by zero or more characters, followed by any capital letter from A to Z, followed by (.

Finally, try PrintAsT???, which will match any string starting with PrintAsT followed by any three characters.

Search in Files Tool

The Search in Files tool is the most powerful search option available in Wing IDE. It supports multi-file batch search of the disk, project, open editors, or other sets of files. It can also search using wildcards and can do regular expression based search/replace.

search-in-files.png

Before worrying about the details, try a simple batch search on the example1.py file. Select Current File from the Look in selector on the Search in Files tool. Then enter PrintAs into the search area.

Wing will start searching immediately, restarting the search whenever you alter the search string or make other changes that affect the result set. When you are done, you should see results like those shown in the screen shot above. Click on the first result line to select it. This will also display example1.py with the corresponding search match highlighted.

You can use the forward/backward arrows in the Search in Files tool to traverse your results.

File Filters

Next, change the Look in selector to All Files in Project and change your search string to HTML. This works the same way as searching a single file, but lists the results for all files in your project. You can also search all currently open files in this way.

In many cases, searching is more useful if constrained to a subset of files in your projects such as only Python files. This can be done with by selecting Python Files in the Filter selector. You can also define your own file filters using the Create/Edit Filters... item in the Filter selector. This will display the Files > File Types > File Filters preference:

file-filters.png

Each file filter has a name and a list of include and exclude specifications. Each of these specifications can be applied to the file name, directory name, or the file's MIME type. A simple example would be to specify *.pas wildcard for matching Pascal files by name, or using the text/html mime type for all HTML files.

Searching Disk

Wing can also search directly on disk. Try this by typing a directory path in the Look in area. Assuming you haven't changed the search string, this should search for HTML in all text files in that directory.

Disk search can be recursive, in which case Wing searches all sub-directories as well. This is done by selecting a directory in the Look in scope selector and checking Recursive Directory Search in the Options menu.

You can alter the format of the result list with the Show Line Numbers item and Result File Name group in the Options menu, which contains several other search options as well.

Note that searching Project Files is usually faster than searching a directory structure because the set of files is precomputed and thus the search only needs to look in the files and not spend time discovering them.

Multi-File Replace

When working with multiple files in the result set, Wing opens each changed file into an editor, whether or not it is already open. This allows you to undo changes by not saving files or by issuing Undo within each editor.

If you check Replace Operates on Disk in the Options menu within the Search in Files tool, Wing will change files directly on disk instead of opening editors into the IDE. This can be much faster but is not recommended unless you have a revision control system that can get you out of hot water if mistakes are made.

Note that even when operating directly on disk, Wing will replace changes in already-open editors only within the IDE. This avoids creating two versions of a file if there are already edits in the IDE's copy. We recommend selecting Save All from the file menu immediately after each replace operation. This avoids losing parts of a replace, resulting in inconsistent application of a replace operation to the files in your source base.