<p>Let's continue our rapid command-covering pace. In command-mode, you can jump to a particularline by typing <c>G</c>. To jump to the first line of a file, type <c>1G</c>. Note that <c>G</c> is capitalized.</p>

241

<p>If you want to jump to the next occurence of a particular text pattern, type <c>/&lt;regexp&gt;</c> and hit <c>enter</c>. Replace

242

&lt;regexp&gt; with the regular expression you're looking for. If you don't know how to use regular expressions, don't

243

fret -- typing <c>/foo</c> will move to the next occurence of <i>foo</i>. The only thing you'll need to watch out for is when

244

you want to refer to the literal <i>^</i>, <i>.</i>, <i>$</i> or <i>\</i> characters. Prefix these characters with a backslash (<i>\</i>), and you'll

245

be set. For example, <c>/foo\.gif</c> will search for the next occurence of "<i>foo.gif</i>".</p>

commands out in your very own vi editor. You can also type <c>//</c> to repeat the last search.</p>

248

249

</body>

250

</section>

251

</chapter>

252

<chapter>

253

<title>Saving and Editing</title>

254

<section>

255

<title>Save and save as...</title>

256

<body>

257

<p>We've covered how you can use the <i>ex</i> command <c>:q</c> to quit from vi. If you want to save your

258

changes, type <c>:w</c>. If you want to save your changes to another file, type <c>:w filename.txt</c> to

259

save as <e>filename.txt</e>. If you want to save and quit, type <c>:x</c> or <c>:wq</c>.</p>

260

<p>In vim (and other advanced vi editors, like elvis)<c>:w</c>, you can have multiple buffers open at once. To open a file into a new window, type <c>:sp filename.txt</c>. <e>filename.txt</e> will appear open for editing in a new split window. To switch between windows, type <c>&lt;CTR&gt;w&lt;CTR&gt;w</c> (control-w twice). Any <c>:q</c>, <c>:q!</c>, <c>:w</c> and <c>:x</c> commands that you enter will only be applied to the currently-active window.</p>

261

</body>

262

</section>

263

264

<section>

265

<title>Simple edits</title>

266

<body>

267

<p>Now, it's time to start learning some of the simple editing commands. The commands that

268

we'll cover here are considered "simple" because the commands keep you in command mode. The

269

more complex editing commands automatically put you into insert mode -- a mode that allows

270

you to enter literal data from the keyboard. We'll cover those in a bit.</p>

271

<p>For now, try moving over some characters and hitting <c>x</c> repeatedly. You'll see that <c>x</c>

272

will delete the current character under the cursor. Now, move to the middle of the paragraph

273

somewhere in your text file, and hit <c>J</c> (capitalized). You'll see that the <c>J</c> command tells

<li><urilink="http://www.vim.org">The vim homepage</uri> is the place to go for all your vim needs.</li>

497

<li>If you're looking for a good, old-fashioned book, <urilink="http://www.oreilly.com/catalog/vi6/">Learning the vi Editor, 6th Edition</uri> would be an excellent choice. Contains good coverage of vi and vi clones.</li>