<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2002-2-1 (1.70)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<html>
<head>

<title>Using Ranges</title>
<meta name="description" content="Using Ranges">
<meta name="keywords" content="vimforwriters">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="LaTeX2HTML v2002-2-1">
<meta http-equiv="Content-Style-Type" content="text/css">

<link rel="STYLESHEET" href="/woodnotes/vim-for-writers/vimforwriters.css">

<link rel="next" href="node18.html">
<link rel="previous" href="node16.html">
<link rel="up" href="vimforwriters.html">
<link rel="next" href="node18.html">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8787127231593738" crossorigin="anonymous"></script>

<script data-grow-initializer="">!(function(){window.growMe||((window.growMe=function(e){window.growMe._.push(e);}),(window.growMe._=[]));var e=document.createElement("script");(e.type="text/javascript"),(e.src="https://faves.grow.me/main.js"),(e.defer=!0),e.setAttribute("data-grow-faves-site-id","U2l0ZToxN2MyMDI0Yi01NmU1LTQ1MjUtYTM4NC1lNTk2MTExMzJhNzI=");var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t);})();</script>

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-9V0ZTBE59R"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-9V0ZTBE59R');
</script>
</head>

<body>
<!--Navigation Panel-->
<a name="tex2html286" href="node18.html">
<img width="37" height="24" align="BOTTOM" border="0" alt="next" src="/woodnotes/vim-for-writers/next.png"></a> 
<a name="tex2html282" href="vimforwriters.html">
<img width="26" height="24" align="BOTTOM" border="0" alt="up" src="/woodnotes/vim-for-writers/up.png"></a> 
<a name="tex2html276" href="node16.html">
<img width="63" height="24" align="BOTTOM" border="0" alt="previous" src="/woodnotes/vim-for-writers/prev.png"></a> 
<a name="tex2html284" href="node1.html">
<img width="65" height="24" align="BOTTOM" border="0" alt="contents" src="/woodnotes/vim-for-writers/contents.png"></a>  
<br>
<b> Next:</b> <a name="tex2html287" href="node18.html">Multiple Windows, Buffers, and</a>
<b> Up:</b> <a name="tex2html283" href="vimforwriters.html">The Woodnotes Guide to</a>
<b> Previous:</b> <a name="tex2html277" href="node16.html">Searching and Replacing</a>
 &nbsp; <b>  <a name="tex2html285" href="node1.html">Contents</a></b> 
<br>
<br>
<!--End of Navigation Panel-->

<h1><a name="SECTION000130000000000000000">
Using Ranges</a>
</h1>
 In the Larry/Moe example above, the <tt>%</tt> 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 <tt>*</tt> instead of <tt>%</tt>.  Figure <a href="#ranges">10</a> shows the other
options at your disposal.

<p>

<div align="CENTER"><a name="ranges"></a><a name="264"></a>
<table>
<caption align="BOTTOM"><strong>Figure 10:</strong>
Ranges</caption>
<tr><td><img width="371" height="127" border="0" src="/woodnotes/vim-for-writers/img10.png" alt="\begin{figure}\begin{tabular}{ll} Range &amp; Key \ \hline
Use , or ; to separate ...
...Entire file &amp; \% \ Visual area
&amp; * \ Mark t &amp; 't \ \end{tabular} \end{figure}"></td></tr>
</table>
</div>

<p>
Here are two examples: 
<dl>
<dt><strong><tt>.,$s/German/French/g</tt></strong></dt>
<dd>``From the cursor's
current position to the end of the document, replace German by French.''
</dd>
<dt><strong><tt>*s/Zune/iPod/gc</tt></strong></dt>
<dd>``Within the visual area, change all occurrences of Zune with iPod, and confirm each replacement.''
</dd>
</dl>

<p>
<br><hr>
<address>
Benjamin Gray
2009-08-04
</address>
</body>
</html>

