Wing IDE provides several different interfaces for searching your code. Which you use depends on your task.
A quick way to search through the current editor is to enter your search string in the area provided in the toolbar:
If you enter only lower case the search will be case-insensitive. Entering one or more upper-case letter causes the search to become case-sensitive.
Try this now in example1.py: Type GetItem in the toolbar search area and Wing will immediately, starting with the first letter typed, search for matching text in the editor. Notice that if you press the Enter key, Wing will move on to the next match, wrapping around to the top of the file if necessary.
Toolbar-based searches always go forward (downward) in the file from the current cursor position.
If you prefer to search without your fingers leaving the keyboard, use the key bindings given next to the Mini-search items in the Edit menu (the bindinges vary by keyboard personality).
From here, you can initiate searching forward and backward in the current editor, optionally using the current selection in the editor as the search string. You can also initiate replace operations.
Try this in the example1.py file: If using the default editor mode, press the Ctrl-U. If you are using emacs mode, press Ctrl-S. For others, refer to the Mini-search group in the Edit menu.
This will display an entry area at the bottom of the IDE window and will place focus there:
Continue by typing G, then e, then t. Notice how Wing searches incrementally with each keypress. This lets you type only as much as you need to find the source code you are looking for.
While the mini-search area is still active, try pressing the same key combination you used to display it again (Ctrl-U or Ctrl-S in emacs mode) and Wing will search for the next matching occurrence. Note that if no match is found Failed Search will be displayed. However, pressing the mini search key combination again will wrap around and start searching again at the top of the file.
As in the toolbar search, typing lower case letters results in case-insensitive search, and using one or more upper case letters results in case-sensitive search.
Search direction can be changed during searching by pressing the key bindings assigned to forward and backward mini-search. You can exit from the search by pressing the Esc key or Ctrl-G in emacs mode.
The regular expression based search options found in the Mini-search menu group work similarly but expect regular expressions for the search criteria (see below).
Keyboard-driven mini-replace also works similarly, except that you will be presented with two entry areas, one for your search string and one for the replace string. Use Query/Replace to be prompted for Y and N for each replace location, and Replace String to replace all matches globally in the file.
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.
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.
When the Show Replace item in Options is activated, Wing will show an area for entering a replace string and adds Replace and Replace All buttons to the Search tool:
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.
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 *, ?, or ranges of characters specified within [ and ]. 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 find matches, all occurrences of the string PrintAs, followed by zero or more characters, followed by (:
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, followed by (.
Finally, try PrintAsT???, which will match any string starting with PrintAsT followed by any three characters (? matches any single character).
Wild card searching can be very useful for finding related source symbols all at once.
Regular Expression Search
Regular expressions can also be used for searching. These are most useful for complicated search tasks, such as finding all calls to a particular function that occur as part of an assignment statement.
For example, open\(newscache( )?,.*\) matches only calls to the function open where the first argument is named newscache and there are at least two parameters. If you try this with example1.py, you should get exactly one search match:
The details of regular expression syntax and usage can be very complicated, so this tutorial does not cover them. For that, see the Regular Expression Syntax documentation in the Python manual.
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.
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 manager (these are the defaults). 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 manager to traverse your results.
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 better constrained to a subset of files in your projects. For example, only Python files. This can be done with by selecting Python Files in the Filter selector. You can also define other file sets using the Create/Edit File Sets... item in the Filter Selector. This will display the File Sets preference:
Each file set 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.
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 also 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 Selector. The Option Selector contains various 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.
When working with multiple files in the result set, Wing will by default open 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.
An alternate replace mode is also available from the Options menu. If you check the Replace Operates on Disk item, 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 when 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 closing all editors when working in Replace Operates on Disk mode, or select Save All from the file menu immediately after each replace operation. This avoids losing parts of a replace, which might lead to inconsistent application of the replace operation to the files in your source base.
|« 1.7. Tutorial: Source Browser||Table of Contents||1.9. Tutorial: Source Assistant with Classes »|