Search And Replace
Find Word Under Cursor
A quick way to find the next or previous occurrence of the word under the cursor can be done by using the Ctrl+Alt+Up or Ctrl+Alt+Down keys available in most keymaps, or by using Shift or Ctrl with the right mouse button (Shift + Right Click searches up, Ctrl + Right Click searches down). If the word under the cursor is not already in a block mark, then hitting one of these keys will block mark the word and will move to the next or previous matching word on the next keystroke. A phrase can also be searched for in this manner, but it will need to be block marked before hitting the search keys.
Incremental Search
Multi-Edit's powerful incremental search feature allows you to perform simple searches with ease. Place the cursor at the position from which you wish to begin searching, select Search | Incremental Search, and begin typing the string of characters for which you would like to search. Multi-Edit will search for the string as you type it in, highlighting the next occurrence of the search string in the file. Thus, you may not need to input the whole string to find the text you're looking for.
Incremental Search will not enter the last entered character into the search string if the search fails. In addition, the search string is not inserted into the normal search string variable so that a repeat search can be done.
The incremental search feature has no dialog box (keep an eye on the Status Bar for progress), but the following keys control its actions:
| Key | Description |
|---|---|
| Esc: | Cancels the search and returns the cursor to its original position before the search began. |
| Alt+P: | Searches backward for the next occurrence of the current search string. |
| Alt+N: | Searches forward for the next occurrence of the current search string. |
| Backspace: | Removes the last character from the search string and returns the cursor to the previously found string. |
| Alt+W: | Performs a word search. When this option is invoked, the incremental search will ignore instances of the search string that are not complete words (i.e. will not find the string “ear” in the middle of the word “search”). |
| Alt+C: | Activates case-sensitive searching. When this option is selected, the incremental search will treat the search string as case sensitive. By default, the string is considered case-insensitive. |
To end the incremental search, press any cursor movement key (arrow key, home, end, etc.).
Find, Find & Replace
When it comes time to locate text and possibly replace it, nothing is easier than using the Find and Replace dialogs. From these dialogs, it is easy to set up different kinds of searches from literal text to search using a regular expression. Below are some tips on how to use these dialogs to quickly locate the text that needs to be found.
• The Find and Replace dialogs are actually part of a set of search related dialogs that appear in a tabbed dialog with tabs for each of the other dialogs. The Find and Replace dialogs are used to quickly search or search and replace text in files that are currently loaded into Multi-Edit. The main difference between the two dialogs is the Replace dialog has an additional text field used to specify the replacement text. Most of the other options operate exactly the same in either dialog.
• The first thing to set when doing a find is to set the type of search that is desired. Selecting one of the Type radio buttons does this. The options are {Literal | Regular Expression | Word/Phrase search}.
o The Literal type is used when simple text is being searched for. It will cause the search engine to locate text exactly as entered into the Search for field, ignoring the case of the characters unless the Case Sensitive option is checked. Since the search engine can only find simple text, it can do so at a much faster rate than the other types of searches.
o Regular expression searches are useful for locating variable length text, multiple words, and more complex text patterns. When this option is checked, a number of characters, called metacharacters, take on special meaning (see the section Regular Expressions below for more details about what each of the supported characters does). If the string entered into the “Search for” field does not contain any of the special characters the search engine will revert to doing a literal search, which is usually faster. The time it takes to search using regular expressions depends upon the particular expression. The Alias button makes it easier to use regular expressions by saving commonly-used expressions under a name you can quickly enter into the “Search for” field. In addition, clicking the arrow button to the right of the “Search for” field drops down a menu listing the metacharacters available for the regular expression style currently in effect; clicking an item inserts it into the field at the current cursor position. The regular expression type: Classic Multi-Edit, Unix, or Perl, is set under the Options tab, or via the Tools | Customize | Search menu.
o The Word/Phrase search is used when looking for a literal phrase that might cross line boundaries. (Note that this option is only available when searching loaded files and thus cannot be used when doing multiple file searches.)
Searches normally scan the complete line but can be restricted to search between specific columns by enabling the Columns option and setting the Start and Stop column numbers. Usually a search only searches the current window and when it finds a match, it stops and highlights the matching text. If the Search all windows options is checked, the search engine will first search the current window, and then continue searching other loaded windows until a match is found or it wraps back to the current window. Also, if the Auto wraps at beginning and end of file option in the Search Options dialog is checked, then the search engine will continue searching after wrapping to the top or bottom of the window. See the Search Options help for more information about each of these options.
• If a list of all matches needs to be found, then selecting the ‘All’ button instead of the ‘Search’ button will cause the search engine to continue finding matches and inserting an entry for every match in a Find list. There can be multiple Find lists, but the user interface only supports two and is selected by picking one from the File list option. The purpose for multiple Find lists is so a File Find can be performed, then allow for searching the results of that File Find for some other text without the need to navigate through the tree to load the next result. See Using a Find View (below) for more information.
• Most of the above holds true for the Replace dialog as well, except that now the Replace button becomes activated when a match is found so that the matching text can be replaced with the replacement string. Regular expressions are also supported in the Replace string and the additional button for inserting them is also available.
File Find, File Find & Replace
The File Find and File Replace dialogs are also part of the Search tabbed dialog and are used when multiple files need to be searched which are not loaded in Multi-Edit. Searching multiple files can take a long time, especially if they each need to be loaded into Multi-Edit and then searched. Therefore, File Find and File Replace use a slightly different search engine to allow speeding up the searching of files. Since only part of each file is ever loaded, the Phrase type searches are not supported; however, regular expressions are still available.
When searching for text in multiple files, a filespec and a starting path can be provided. Both of these fields can have multiple entries by separating them with a semicolon. When the Filespec field is left blank the search engine will use *.* as the filespec, and when the Starting Path field is blank the current path is searched. If the Search For field is left blank, then a list of all of the files matching filespec will be added to the list.
When a project is defined, the “Limit search to project list” option is made available. This option, when checked, will cause the search engine to search the files in the project list of the files in the paths specified in the Starting path field.
A File Find or File Replace always generates an entry in one of the Find lists. The purpose for multiple Find lists is so a File Find can be performed, then the resulting list of files allow for searching the results of that File Find for some other text without the need to navigate through the tree to load the next result. When a search is started, a new top-level tree node is inserted showing the parameters of the search. If there are matches found in a file, then a second level node for each file is inserted into the tree. When the “List all occurrences” option is checked, then a third level node for each found item in the file is inserted into the tree. See Using a Find View (below) for using the lists.
File Replace
Search | File Replace is used when replacements are to be done in multiple files, including those that are not currently loaded into Multi-Edit.
This is similar to the File Find dialog, but after all of the matches are found and listed in the Tool Pane, the files are then opened and the replacements can be performed.
Using A Find View
The find lists are the results of doing either a Find File or a Find All. Multiple search results can be shown in a single find list since it uses a tree view. A new top-level node will be added to the top of the tree whenever a new search is done. There can be up to three levels for each search depending upon the options selected. The top-level entry, Find nodes, contains the information about the search, such as the string being searched for, the file mask, and the total found count. The second level entry, File nodes, contains the name and path of the file where a match was found. It can also contain the number of times the string was found in the file. The third level entry, Found nodes, are generated whenever a Find All or the List All Occurrences option in the File Find dialog is enabled. This level shows the line number the string was found on and the text of the line.
Moving through the tree list can be done by using either the mouse or the cursor keys. To expand and collapse the tree, use either the left/right arrow keys or click on the +/- icon in the first column. The Open and View buttons have the same function except for where the focus is left; the focus will be in the tree list after the View button is used and in the opened file if the Open button is used. The Open/View buttons change behavior depending upon which level node is active when they are selected. If a Find node is selected, the appropriate search dialog will be opened and set up to allow a new search with the same parameters to be done when one of these buttons is hit. When a File node is selected, the file specified will be loaded and the cursor moved to the first match. When a Found node is selected, the specified file is loaded and the cursor positioned to the line of the selected found line. To remove a node, the Delete key can be used.
In addition, a context menu is provided via a right click on the mouse, that allows doing all of the above with the mouse.
A special menu button near the upper left corner of the Find list (a button with a triangle arrow on it) provides the ability to manipulate the tree list as a whole. From this menu, the data can be saved to disk (Save), loaded from disk (Load), exported to a text file (Export), or the list can be cleared (Clear All). To quickly access this menu using the keyboard when in the tree control, hit the Tab key and then the Space key to bring up the menu.
Expression Highlight
This allows you to specify a search string or expression and see all occurrences of the found text highlighted in all of your files. This is dynamic; you may edit the files just like normal without disturbing the highlighting.
The Prompted Search option allows you to find one occurrence at a time.
The Search | Global Expression Highlight dialog contains the same fields as in the Tools | Customize | Search | Hilite dialog (where you may modify the default search settings), with the addition of the following:
• Highlight: Enter in this field a string or regular expression to highlight throughout your currently loaded files.
• ‘Alias’: This button brings up the Regular Expression Aliases dialog. These Search Aliases are pre-defined regular expressions that you can easily set up, modify, and use in your search strings.
• ‘Reg Ex Help’: This button invokes Help on Regular Expressions.
• Regular Expression Insert button(Triangle button to right of Highlight field): This button allows selecting a regular expression character from a popup menu to be inserted into the string field at the cursor position.