10. Search and Replace

The simple search is used to find and replace text in the current editors file buffer. It has the same functionality then the incremental search but a traditional dialog based useability. Which one you prefer belongs to your personal preferences.

How to invoke the 'Simple Search'?

Simple Search/Replace Dialog

The Search and the Replace dialogs look mostly the same so we descibe both of them together. If you have selected text when invoking the dialog, the selection will be set as the initial search text.

Search Text

Enter your search text here. If you checked the "Regular Expression" option it must be a PCRE Regular Expression, otherwise it can be any text.

Case Sensitivity

You can select three different styles how character case should match:

  • If contains capital letters
    This is the default and is inspired by the EMACS Editor. The search is case insensitive as long as you only type lower case letters. This heuristic works well in most cases but fails from time to time when you start with a selection or with a regular expression if you type upper case control characters.

  • Always
  • Never
Regular Expression

Check this option if you want to use PCRE Regular Expression matching.

Whole Words

If you check this option, then the character just before the result and the character just after the result are checked if they are a letter, digit or underscore. In this case the result is skipped and search continues.

Search Direction If checked the search will start at the caret position and go up to the begin of the document. Otherwise it will go to the bottom of the document. When you are questioned if you want to continue searching after reaching the end of the search text, the search direction will be keept. So a "search up" will restart at the bottom of the document while a normal search will start at the begin of the document.
Search Selection Check this if you want to restrict the search to the currently selected text in the editor buffer.
List Result If you check this then search does not simply select the first result, instead it finds all results matching the query and lists them in the Searches" tool pane, like the power search does.
Replace Text

Put the replacement text for a found match here. If you leave it empty the found text is removed.

When you search with a regular expression you can reference the match and its subexpression as follows:

  • \0 stands for the complete match
  • \n with n being one or more digits references the n-th subexpression of the match.
  • \(n) does also reference the n-th subexpression. You must use this form when the text following the 'n' does start a digit.
  • \\ is the escape sequence for the backslash character
  • \<name> references a named subexpression with the given name.
  • If you place a 'l', 'u' or 'i' character behind the initial backslash then the matched data is converted to lower case, upper case or inverted case before it is used in the replacement.
Previous in History

The parameters which which you started all simple search and replace operations are stored in a history list of 20 items (with duplicates removed). Use this button to go back the previous search options.

Use Ctrl-P as shortcut key.

Next in History

After you hit the "previous in history" button at least once, you can use this button to go forward again in the history list.

Use Ctrl-N as shortcut.

After you hit okay the find dialog will save its current state and close itself before the first find result is selected.

Replace Confirmation Dialog

The replace dialog will instead come up with a simple confirmation dialog for each found match. The position of the dialog is changed on each found text to not cover the matching text.

In this confirm dialog you can:

Next

Do nothing with this match and find next one match.

Last

Replace this match and end the operation.

List

Stop here and start a power search with the same options which display its results in the Searches" tool pane

Replace

Replace this match and then find the next one.

Replace All

Replace this and all other matches without asking again. You must be sure that your search is not resulting in false positive matches when pressing this button.

Cancel

End the operation without replacing this match.

This dialog has a special convenient feature. The key shortcuts to the six possible actions are not only registered with in the there "Alt-F", "Alt-L" etc. form but also as direct shortcuts. So you can just type F or R to "Find Next" or "Replace".

Incremental search is the fastest way to search in the current editor buffer and is usually preferred over the simple find dialog by most people.

You start the simple search by

Once you invoked the incremental search you will see a little window on the top side of your editor window saying "Search For:". Now type your search text and the caret will move to the next matching location while you type.

The incremental search has defined some keys to change options and control the search operation.

If you start the incremental search, the current selected text is used as initial value. But if there is no selection, the initial value is the word at the caret location, if any.

So if you want to lookup a word in the current buffer just place the caret over the word and hit Ctrl-I Ctrl-L. This gives you a list of this word in the current editor buffer. The "Lookup Selection" mechanism is doing the same but in multiple files.

The 'Power Search' feature let you search and replace text in the editors current file buffer or in multiple files. The results of a power search will always be shown in the "Searches" tool pane. You have a wide range of options to specify exactly the files you really want to search.

The search is based on three 3 items:

The power search will compute first the file search list, then the file exclude list after this remove all items from the search list which are also in the exclude list. Then a text operation is applied to each file content replacing some parts of the file with spaces and then the normal string or regular expression search starts.

You invoke the 'Power Search' by

After you invoked the power search, a dialog with three tab pages opens. We now describe all options on these pages.

a) Text Search Options

Search Text

Enter the search text here, use a PCRE regular expression if you check the 'Regular expression' option.
You can only search for text which is completely inside one line.

Replacement Text

Enter your replacement text here. If you leave it empty then the found text is removed. If you search with a regular expression then you can use references in the replacement text to refer to matched subexpressions.

References are written as \n or \(n). The value 0 referes to the full match, values greater then 0 refer to the n-th subexpression starting counting from left-to-right.

Enable Replace

You must check this option to enable the replace functionality.
Having a separate replace option makes it possible to use the same dialog for replace and find operations.

Search Text Options
  • Case sensitive
  • Whole words only
  • Regular expression
Syntax Highlighting Filter

If you check the 'Use Syntax Filters' you can restrict the search to some parts of the selected text file.

This features uses the editors syntax highlighting code. For some complicated situations in files like 'ruby' this means that there are a few special cases where the syntax classification is not 100% correct. Other Editors call it therefore 'chroma search'.
  • Search only Text matching Syntax Filter
    If this option is selected then all characters not in the specified syntax colors are replaced by space characters before the search is done.
  • Ignore all Text matching Syntax Filter
    With this option the all characters with the specified syntax colors are replaced by space characters before the search is done.

File Text Range

If you do not specify any files then the search will be in the current file buffer. In this case you can use this four options to specify the text range where to search.

Last Search

Arachno keeps a history list of your last 20 power searches.
Clicking here replaces all values in the dialog with the values from the previous search.

Next Search

After you hit the 'Last Search' button at least once, you can use this button to go forward in the history list.

Save Search Operations

This popup menu button bundels all commands to load and store sets of search parameters. We will explain this later in section Named Searches.

Error Indicator

Whenever there is a problem with your input Arachno will show a small error icon like this. Here it is displayed because the 'Find what' parameter is mandatory.

b) The File Options Page

File Sets If you do not check at least one of this four options the search will only happen in the editors current file buffer.
  • All Open Files
    Adds all files that are open in the editor to the file search list.
  • All Runtime Files
    Adds all files from the current Python runtime to the file search list.
  • All Project Files
    Adds all files from the project directories and virtual hotfile folders to the file search list.
  • All in File List
    Adds all files that are listed in the file list below to the file search list.
    As explained later this file list is also used to populate the exclude file list and so remove certain files from being searched.
File Types Specifiying a file type is the simplest of all file filters. If you select something else then "[All Files]" here then only files of this type are searched. The file type is detected by looking at the files extension and checking against the values you specified in the File Type Settings.
File Name Filter With the file name filter you can filter files with certain names from the search list. If you do not specify any other name filter option a file is searched if the file name does contain the string you entered here.
Name Filter Options

Options for the file name string you inserted above.

  • Regular Expression
    If checked then the 'File Name' value must be a valid PCRE regular expression. If the regular expression matches the whole file name or file path then the file is searched.
  • Case sensitive.
    If checked the substring test or the regular expression match will not ignore the character case.
  • Use complete File Path
    If checked the substring test or regular expression match test will happen on the whole simplified absolute file path. The file path is simplified, which means all '.' and '..' path fragments are correctly substituted.
File Browser Buttons Each of this buttons opens a dialog window where you can select a directory, multiple files or a hotfile folder and add the paths into the file list window.
File and Directory List

This is a text edit widget where you give a list of all files and directories that are added to or excluded from the file search list. All directories must end with a trailing '/' or '\' character.

  • Add a '*' character as the first (non whitespace) character of a directory line and the directory is recursively traversed and all files in the whole tree are added to the file search list.
  • Directories and Files that are ignored (for example ".svn" or ".cvs") by the project are not be added to the file search list. You can configure the ignore patterns for files and directories in the file or project settings dialog.
  • Virtual hotfile folders from the project are identified by using the form "[Folder-Name]".
  • If a line starts with '-' then that the item on the line, which might be either a directory or a file, is added to the file exclude list.
  • It is possible to use the '-*' prefix to exclude a complete directory tree.
  • It is not possible to add files or directories that start with the special prefix characters '*', '-' , '-*' or '['
  • All relative file paths are resolved the the project base directory.
  • You can use environment variable expansion on all lines.

c) The Syntax Highlighting Filter Page

Programming Language

You can use the syntax coloring of all known language. Once you have at least checked one element for a language, a small green check mark is set for easy recognition. Please keep in mind that a file might contains multiple languages, for example Python Server Pages can contain HTML and Python code.

Colorized Syntax Elements

Here you find check boxes for all the differnt syntax colors in the language.

Text Sample

This is an example text fragment from the lanugage showing the individual syntax highligher parts.

Named Searches

You can save the current state of all dialog options under a name for later reuse.

Use the save icon in the lower left of the dialog to open menu and then select "Save current Settings..."

This will open a small dialog where you can specify a name, a numeric prefix and if you want to save this query in the project or the global settings. If you select the former the search will only be available in windows that display the current project.

The prefix key gives you a way to automatically start the dialog with this settings. To do this give the "Power Search" start command a numerical prefix by typing Cntrl-<number> followed by the invocation key Ctrl-Alt-F for example typing the sequence Ctrl-1 Ctrl-2 Ctrl-Alt-F starts the "Power Search" dialog and initializes it with the named search that has the prefix code 12.

Once you have defined a named search you can also press the search toolbar icon for longer then 500 milliseconds and a menu with all available named searches comes up.

As described later there is one special reserved name.
If you assign the name "Lookup Selection" (this is case sensitive) it will be taken as the default for the Lookup Selection mechanism.

There is no way to edit a named search values. If you want to change it, then select the named search from the menu, make your changes in the dialog and use the "Update with current settings" with the same name.

Configure Highlight Dialog

10.6. Search Result Toolpane

10.7. Grep Toolpane

Match Mode

Filepath

Matching Preview

Matching Result View

Count Mode

Match Counter

Filepath

Collect Mode

Match Group Summary

Match Group Counter

Replace Group Summary

Replace Group Counter

Replace View