From Wenlin Guide

Jump to: navigation, search

Wenlin 216x93.png Chapter 10 of the Wenlin User’s Guide

This chapter describes all of Wenlin’s searching capabilities, including the commands in the Search menu and the ▷search buttons in dictionary entries.

You can conduct searches to find practically any string of text, in any window, file, or collection of files. And when you are editing, you can use search and replace to find a string of text and replace it with another.

Wenlin offers two kinds of searches: local and global. A local search takes place within the active window. A global search can go through an entire collection of files (Search Files...) or through the dictionaries (Search Dictionaries...), both of which are good ways to find examples of vocabulary usage in context.


Local Searches: Searching Within the Active Window

Wenlin provides the following commands for local searches:

  • Find...
  • Find Again
  • Replace
  • Replace and Find Again
  • Replace All
  • Find Fix:

You can choose the commands from the Search menu or you can use keyboard shortcuts. As a precaution, Replace All has no keyboard shortcut. The replacement commands are only available when editing is enabled in the active window.

The primary command is Find... , which opens a dialog box prompting you for information. All the other commands (except Find Fix:) rely on the information you specify in the Find... dialog box.

The text you search for can be any sequence, or string, of characters. It is called the search string.

For example, if you want to search for a particular word, simply choose Find... , type the word you wish to find, and choose OK. Wenlin then conducts a forward search from the current position of the insertion point. If the word is found, Wenlin automatically scrolls to where it is and highlights it. Suppose you want to find the next instance of the word. There is no need to type the word again. You can use the Find Again command. The Find... dialog box stores the search string, and the Find Again command searches for the next instance of the same search string.

The Find... command is also used in combination with the replacement commands. From the Find... dialog box you can specify both the search string and the string of text to replace it with. You then have all kinds of options available. You can choose Replace All (taking appropriate precautions!) or you can judiciously go through the document and make replacement decisions on an individual basis. Here you might use a combination of commands. First you use Find... . When the search string is found, it is highlighted. You can then choose Replace and be satisfied, or you can choose Replace and Find Again to continue forward. If you don’t want to replace the highlighted string, you can choose Find Again and continue forward without replacing it.

The Find Fix: command has a very specific purpose, related to the Make Transformed Copy... command in the Edit menu. It is described in Chapter 8.

The Insertion Point and Local Searches

The insertion point plays a crucial role in all the local search commands. Wenlin always searches forward, starting from the current position of the insertion point in the window. Therefore, if you want to search an entire document, you may want to start with the insertion point at its very beginning. However, the Find and Find Again commands, when reaching the end of a document, present a dialog offering to continue searching from the beginning of the document.

Whenever the search string is found, it will be highlighted and visible. Highlighted text is also the selection, and it acts as the insertion point. Therefore, when editing is enabled, the highlighted text can be easily replaced by choosing Replace or by pressing any keystroke that would normally cause text to appear (or disappear) at the insertion point. The insertion point is described in detail in Chapter 1.

The Find Dialog Box

When you choose Find..., this dialog box is displayed:


There are two text boxes, one for the search string, another for the replacement string. Depending on your purpose, you put text in one or both of these boxes. To move the insertion point between boxes, press the Tab key, or point to the box of interest and click.

Normally, if you search for a word like “cat”, Wenlin also finds any occurrence of “CAT” or “Cat”, regardless of whether it is written in capital or small letters. Similarly, if you search for a Chinese word or phrase, Wenlin finds it regardless of whether it is written in simple or full form characters: if you search for 见 (jiàn ‘see’), Wenlin also finds any occurrence of 見 (or vice-versa). Usually, this is very helpful. Occasionally, however, you might want to search for a string written exactly as you specify it; in that case, you can click on the check box:


Normally, the “Full=simple” check box has a mark in it. If you un-check it (remove the mark), the search will be exact, that is, 见 won’t match 見, 猫 won’t match 貓, and “cat” won’t match “Cat”.

The Find dialog box accepts any text that you would normally be able to place on the screen by typing, pasting, or using the Grabber. You are only limited by the size of the Find dialog text boxes.

Wenlin will find the string inside another, larger string. For example, if you look for the string “the” it will be found inside the strings “theory” and “mother”.

Examples of Local Searching

Below we give instructions for using Find... and the other local search commands, in some typical situations.

By local we mean that you are searching within a file that is currently open in a Wenlin window or sub-window (in contrast to global searches discussed below).

Finding a String

To find a string of text in a window:

• Choose Find... from the Search menu
• Place the search string in the dialog box
• Choose OK

If the string is in the window (somewhere following the insertion point), Wenlin scrolls to where the string is and highlights it. If the string isn’t found, the computer emits a beep. Wenlin always searches to the very end of the document, not just the visible portion in the window.

To find the next instance of the same string, choose Find Again from the Search menu.

Replacing a String

To find a string and replace it with another string:

• Choose Find... from the Search menu
• Place the search string in the dialog box
• Place the replacement string in the dialog box
• Choose OK

If the string is in the window, Wenlin scrolls to where it is and highlights it. You can then choose any of the following commands from the Search menu:

Replace to replace the highlighted string with the replacement string</li>
Replace and Find Again to replace the highlighted string and then search for the next instance of the search string
Find Again to search for the next instance of the search string

Replacing All

To replace every instance of the search string:

• Position the insertion point where you want the replacements to start
• Choose Find... from the Search menu
• Place the search string in the dialog box
• Place the replacement string in the dialog box
• Choose OK

When the first instance of the search string is found,

• Choose Replace All from the Search menu

Wenlin then makes all subsequent replacements and tells you how many instances were replaced. If a replacement string is not stored in the Find dialog box, every instance of the search string will be replaced with nothing, that is, deleted! Use caution with Replace All. Before you make wholesale replacements in a document, make sure that you have a copy saved on disk. If you want, you can open up a duplicate, read-only window to use later for comparison.

After you have placed the search string and/or the replacement string in the dialog box, you are free to choose any of the other commands at any time. For example, you can select some text yourself (using the mouse or keyboard) and then choose Replace. Moreover, text needn’t be highlighted to use Replace – Wenlin always inserts the replacement string at the current position of the insertion point. The search string and the replacement string will remain in the Find dialog box until you change them, delete them, or quit the program.

Regular Expressions

For programmer-linguists, Wenlin supports regex (Perl-Compatible Regular Expression) searching. If you type re= into the Find text box, Wenlin performs a search on the regex pattern after the re= prefix. Detailed documention of regex usage is beyond the scope of this documentation; please see the [] and [] websites.

Here are a couple of examples:


(Find all lines beginning with the string da.)


(Match Unicode hexadecimal digits given in Wenlin's "[U+xxxx]" bracketed USV notation, storing the digits in the variable $1 for use in the Replace slot. Enabling the "Full=simple" option will perform a case-insensitive search.)

Regular expressions can also be used for the Search Files and Search Dictionaries commands (described below).

$1 through $9 (only) in the replacement string stand for matched parenthesized subexpressions.

One limitation is that simple and full form characters (like 马 and 馬) are not treated as equivalent, although the abc=ABC option is supported for case-insensitivity. (You can explicitly search for re=马|馬 to match either 马 or 馬.)

Searching is done one line at a time; patterns can't include newline characters, but ^ matches start-of-line and $ matches end-of-line.

Regular expressions are a very experimental feature in Wenlin, so be cautious with your important files, especially if you use the Replace All command.

Common Mistakes when Using Find

  • You used the wrong spelling, or the wrong tone mark.
  • You did not correctly position the insertion point. Searches always take place forward of the insertion point.
  • You inadvertently placed a space before or after the search string.
  • You forgot that pressing the Return or Enter key deletes highlighted text when editing is enabled.

Creative Uses of the Search Features

You can count how many times a certain word or character appears in a document by replacing it with itself. Wenlin will report the number of instances found (and replaced).

You can type more efficiently by using abbreviations and then replacing them later. For example, instead of repeatedly typing in an expression, phrase or title, etc., you can use a short string that never occurs normally. Later, you can use Replace All to substitute the full text for your abbreviation.

Global Searches: Searching a Collection of Files

When you study vocabulary, it’s helpful to see concrete examples of usage, especially examples in an interesting context. Ideally, you would want examples from a variety of literary sources. Global searches provide that capability.

You can also use a global search as a way of locating a file. Perhaps you have forgotten the name of the file but remember some of its contents. Instead of opening up all kinds of different files and looking around (trial and error), you can conduct a search. All you need is an identifiable string – some phrase or expression that is unlikely to appear in other files.

You can initiate a global search two ways: by pressing a ▷search files button inside a dictionary entry, or by choosing Search Files... from the Search menu. All dictionary entries include search buttons. For example, the entry for 的 contains this button:

▷search files for 的

The menu command Search Files is more general: it enables you to search for practically any string of text, even if it’s not a word or phrase in the dictionary. With either method, you can specify the collection of files to search, or you can simply accept the default collection.

Since each ▷search files button is simply a special case of the more general purpose menu command, we describe the menu command first.

The Search Files Menu Command

To conduct a global search:

• Choose Search Files... from the Search menu
A dialog box appears
• Enter the search string in the first dialog box
A second dialog box appears
• Specify a group of files in the second dialog box

Below, we describe these steps in detail.


When you choose Search Files..., a dialog box prompts you for the text to search for. Just as in the Find dialog box described earlier, you can specify any text for the search string. The check box: Full=simple... has the same effect here that it has for the Find dialog (described above). After you choose OK, a second dialog box prompts you to specify the files to search.

Specifying What Files to Search

You can accept the default file specification or you can supply your own. The default behavior is to search all files in the same location as the Wenlin application itself. The dialog box looks and behaves differently, depending on the operating system (MS-Windows or Macintosh). In any case, it resembles the dialog box for opening a document with the Open... command (as described in Chapter 3).





Navigate just as you would to open a document. When the folder you want to search is open, click on the button that says Open or Choose.

There is a check box: Search next file after 3 matches. Normally it has a mark in it, which means that Wenlin won’t look for more than three occurrences in any single document; after finding three occurrences of the search string in a single document, it will go on to search the next document. This way, for a common word, you’ll obtain examples from a wider variety of contexts, instead of seeing a whole lot of examples all from the same document. If you prefer to conduct a thorough search of every single occurrence in every file, however, you can un-check the check box by clicking on it.

Any folders (subdirectories) inside the folder (directory) you specify are included in the search; and any folders inside those folders are also searched, and so on, however deeply the folders are nested. (Technically, we say that the search is recursive.) Therefore, you can easily search through a whole bunch of folders all at once, if they are all located inside a single high-level folder.

Specifying the Default File Format

A pop-up menu enables you to specify a default file format. This setting doesn’t matter if the files are all Unicode, or if they all have extensions that indicate their formats (such as “.gb”, “.b5”, “.u8”, “.wenlin”, as described in Chapter 3). For searching the text files supplied with Wenlin, this setting doesn’t matter.

When Wenlin can’t tell automatically what a file’s format (encoding) is, it uses the default format that you specify here. This is important if you have your own collection of text files, and they aren’t Unicode, and they don’t have extensions that indicate their formats.

While a Global Search is in Progress


After you specify the search criteria, the search begins. A dialog box shows the search progress. It tells you the name of the current file being searched along with the total number of occurrences found so far. If you don’t have time for a complete search, or the search has already yielded plenty of examples, you can interrupt the search at any time by choosing the Suspend button. You can easily resume the search as described below.

Results of a Global Search

When the search is over, or when you suspend it, a window displays the name of each file, the position of the occurrence (numbers which you can ignore), and the line that contains the occurrence.

When a single file contains more than three occurrences, if the Search next file after 3 matches check box was checked, then a line saying ... may have more is shown after the third occurrence. You can always open the file and conduct a local search to find additional occurrences in that file.

Suppose you were interested in archeology; you might search through issues of an electronic Chinese magazine downloaded from the internet for 考古学 (kǎogǔxué ‘archeology’). The search window might look as follows, if you suspend the search for 考古学 after 13 occurrences have been found.

Search /Applications/Wenlin4/Text/HXWZ/ for 考古学
▷"/Applications/Wenlin4/Text/HXWZ/1993/" [40396-40405]:
▷"/Applications/Wenlin4/Text/HXWZ/1993/" [5370-5379]:
▷"/Applications/Wenlin4/Text/HXWZ/1994/" [6328-6337]:
▷"/Applications/Wenlin4/Text/HXWZ/1995/" [20409-20418]:
▷"/Applications/Wenlin4/Text/HXWZ/1995/" [20502-20511]:
▷"/Applications/Wenlin4/Text/HXWZ/1995/" [21072-21081]:
( may have more)
▷"/Applications/Wenlin4/Text/HXWZ/1995/" [46637-46646]:
▷"/Applications/Wenlin4/Text/HXWZ/1995/" [47119-47128]:
▷"/Applications/Wenlin4/Text/HXWZ/1995/" [33061-33070]:
▷"/Applications/Wenlin4/Text/HXWZ/1995/" [33157-33166]:
▷"/Applications/Wenlin4/Text/HXWZ/1995/" [34035-34044]:
( may have more)
▷"/Applications/Wenlin4/Text/HXWZ/1995/" [3441-3450]:
★ 十月三十一日报道,中国考古学家在山西省皋平市(译音)发现一坑
▷"/Applications/Wenlin4/Text/HXWZ/1995/" [5226-5235]:
★ 十一月三日报道,中国考古学家在陕西西安附近发掘了数百冢战国和前
Search suspended. So far 13 occurrences of "考古学" in 7 files.
▷Resume search (373 files already searched, 631 files remain)

To open a file and see the full context of an occurrence, press the ▷triangle button next to the file name. The document will be opened in a new window, which automatically scrolls to show the occurrence, which is highlighted.

Resuming a Search

If you suspend a search, you can always resume it later by pressing the triangle button ▷Resume search, located at the bottom of the search window. For instance, suspending a search for 考古学 could result in a message like this:

Search suspended. So far 13 occurrences of "考古学" in 7 files.
▷Resume search (373 files already searched, 631 files remain)

When you resume the search, it picks up where it left off – it does not duplicate the work already done. The original search window is updated to reflect the results of the resumed search. You can suspend and resume as many times as you like.

Search Files Buttons

Wenlin provides ▷search files buttons inside three types of dictionary entries: Zìdiǎn, Cídiǎn, and Yīng-Hàn. For example:

▷search files for '大'
▷search files for '大家'
▷search files for 'big'

Each button is programmed to search for a particular vocabulary item. Pressing it is equivalent to choosing Search Files from the Search menu and entering that vocabulary item in the first dialog box. You will then be prompted to specify the files to search, exactly as we described earlier for the menu command.

Searching in the Dictionaries

Search in the dictionaries is very similar to searching in files. It is another kind of global search. Not only headwords, but also words occurring in example sentences and definitions can be found this way. It is slower than simply looking up a headword by the methods described in Chapter 5.

Choose Search Dictionaries... from the Search menu and enter the vocabulary item or other string of text for which you want to search. The Cídiǎn, Yīng-Hàn, and Zìdiǎn dictionaries will be searched, in that order. Suspending and resuming are essentially the same as for the Search Files command described above.

Search dict.png

Search Dictionaries Buttons

Wenlin provides ▷search dictionaries buttons inside three types of dictionary entries: Zìdiǎn, Cídiǎn, and Yīng-Hàn. For example:

▷search dictionaries for '大'
▷search dictionaries for '大家'
▷search dictionaries for 'big'

Each button is programmed to search for a particular vocabulary item. Pressing it is equivalent to choosing Search Dictionaries... from the Search menu and entering that vocabulary item in the first dialog box.


zhǎo ‘seek’

From 扌(手 shǒu) 'hand' and 戈 () ‘spear’.

“A 戈 lance in hand: seek an enemy” --Karlgren.

Mouse pointer finger right.jpg | Previous: 9. Editing the Dictionaries | Next: 11. Pronunciation | Contents |

Personal tools