next up previous contents
Next: Multiple Windows, Buffers, and Up: The Woodnotes Guide to Previous: Searching and Replacing   Contents

Using Ranges

In the Larry/Moe example above, the % tells the search command to search the entire document. But searching and replacing is one of the few times a writer might be interested in limiting the effect of a command to a certain range of lines rather than to the entire document. Use visual mode to select a certain part of your document, and then limiting the search and replace to that range with * instead of %. Figure 10 shows the other options at your disposal.

Figure 10: Ranges
\begin{figure}\begin{tabular}{ll} Range & Key \ \hline
Use , or ; to separate ...
...Entire file & \% \ Visual area
& * \ Mark t & 't \ \end{tabular} \end{figure}

Here are two examples:

``From the cursor's current position to the end of the document, replace German by French.''
``Within the visual area, change all occurrences of Zune with iPod, and confirm each replacement.''

Randall Wood 2009-08-04