File: node9.html

package info (click to toggle)
rutebook 1.0-1
  • links: PTS
  • area: non-free
  • in suites: sarge
  • size: 9,476 kB
  • ctags: 1,112
  • sloc: makefile: 47
file content (734 lines) | stat: -rw-r--r-- 27,275 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 99.2beta8 (1.46)
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>6. Editing Text Files</TITLE>
<META NAME="description" CONTENT="6. Editing Text Files">
<META NAME="keywords" CONTENT="rute">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="LaTeX2HTML v99.2beta8">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="rute.css">

<LINK REL="next" HREF="node10.html">
<LINK REL="previous" HREF="node8.html">
<LINK REL="up" HREF="rute.html">
<LINK REL="next" HREF="node10.html">
</HEAD>

<BODY BGCOLOR=#FFFFFF >
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<TR><TD align=left bgcolor="#000000">
<FONT COLOR=white>
&nbsp;<A HREF="http://www.icon.co.za/~psheer/rute-purchase.html"><FONT COLOR=white>Purchase</FONT></A>&nbsp;
</FONT>
</TD><TD align=center bgcolor="#000000">
<FONT COLOR=white>
Copyright&nbsp;&#169;&nbsp;2002&nbsp;Paul Sheer. <A HREF="copying.html"><FONT COLOR=white>Click here for copying permissions.</FONT></A>
</FONT>
</TD><TD align=right bgcolor="#000000">
<FONT COLOR=white>
&nbsp;<A HREF="http://www.icon.co.za/~psheer/rute-home.html"><FONT COLOR=white>Home</FONT></A>&nbsp;
</FONT>
</TD></TR>
<TR><TD colspan=2 align=left bgcolor="#ECEBF4">
<IMG SRC="va-btn-small-light-60.png">
</TD><TD align=right bgcolor="#ECEBF4">
<IMG SRC="sflogo2-steel-60.png">
</TD></TR>
</TABLE><BR>

<!--Navigation Panel-->
<A NAME="tex2html1832"
  HREF="node10.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1828"
  HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1822"
  HREF="node8.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1830"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
<BR>
<B> Next:</B> <A NAME="tex2html1833"
  HREF="node10.html">7. Shell Scripting</A>
<B> Up:</B> <A NAME="tex2html1829"
  HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html1823"
  HREF="node8.html">5. Regular Expressions</A>
 &nbsp <B>  <A NAME="tex2html1831"
  HREF="node1.html">Contents</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>

<UL>
<LI><A NAME="tex2html1834"
  HREF="#SECTION00910000000000000000">6.1 <TT>
<FONT COLOR="#0000ff">vi</FONT></TT></A>
<LI><A NAME="tex2html1835"
  HREF="#SECTION00920000000000000000">6.2 Syntax Highlighting</A>
<LI><A NAME="tex2html1836"
  HREF="#SECTION00930000000000000000">6.3 Editors</A>
<UL>
<LI><A NAME="tex2html1837"
  HREF="#SECTION00931000000000000000">6.3.1 Cooledit</A>
<LI><A NAME="tex2html1838"
  HREF="#SECTION00932000000000000000">6.3.2 <TT>
<FONT COLOR="#0000ff">vi</FONT></TT> and <TT>
<FONT COLOR="#0000ff">vim</FONT></TT></A>
<LI><A NAME="tex2html1839"
  HREF="#SECTION00933000000000000000">6.3.3 Emacs</A>
<LI><A NAME="tex2html1840"
  HREF="#SECTION00934000000000000000">6.3.4 Other editors</A>
</UL></UL>
<!--End of Table of Child-Links-->
<HR>

<H1><A NAME="SECTION00900000000000000000">
6. Editing Text Files</A>
</H1>

<P>
<A NAME="chap:edittextfiles"></A>
To edit a text file means to interactively modify its content. The
creation and modification of an ordinary text file is known as
<I>text editing</I>. A word processor is a kind of editor, but
more basic than that is the U<SMALL>NIX</SMALL> or DOS text editor. 

<P>

<H1><A NAME="SECTION00910000000000000000">
6.1 <TT>
<FONT COLOR="#0000ff">vi</FONT></TT></A>
</H1>

<P>
The important editor to learn how to use is <TT>
<FONT COLOR="#0000ff">vi</FONT></TT>. After that you
can read why, and a little more about other, more user-friendly
editors.

<P>
Type simply,

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>vi&nbsp;&#060;filename&#062;</code><br>
</FONT></TD></TR></TABLE><P>
to edit any file, or the compatible, but more advanced

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>vim&nbsp;&#060;filename&#062;</code><br>
</FONT></TD></TR></TABLE><P>

<P>
To exit <TT>
<FONT COLOR="#0000ff">vi</FONT></TT>, press <IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-esc.png" ALT="Esc">, then the key
sequence <TT>
<FONT COLOR="#0000ff">:q!</FONT></TT> and then press <IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-enter.png" ALT="Enter">.

<P>
<TT>
<FONT COLOR="#0000ff">vi</FONT></TT> has a short tutorial which should get you going in
20 minutes. If you get bored in the middle, you can skip it and learn
<TT>
<FONT COLOR="#0000ff">vi</FONT></TT> as you need to edit things. To read the tutorial, enter:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>vimtutor</code><br>
</FONT></TD></TR></TABLE><P>
which edits the file

<UL>
 
<TT>
<FONT COLOR="#0000ff">/usr/doc/vim-common-5.7/tutor</FONT></TT>,
<BR><TT>
<FONT COLOR="#0000ff">/usr/share/vim/vim56/tutor/tutor</FONT></TT>, or
<BR><TT>
<FONT COLOR="#0000ff">/usr/share/doc/vim-common-5.7/tutor/tutor</FONT></TT>,
</LI>
</UL>
depending on your distribution. <FONT COLOR="#ffa500">[By this you should
be getting an idea of the kinds of differences there are between
different L<SMALL>INUX</SMALL> distributions.]</FONT>You will then see the following at the top of your screen:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red size="-1">
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-2"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-2"><code>10</code></font><code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue size="-1">
<code>===============================================================================</code><br>
<code>=&nbsp;&nbsp;&nbsp;&nbsp;W&nbsp;e&nbsp;l&nbsp;c&nbsp;o&nbsp;m&nbsp;e&nbsp;&nbsp;&nbsp;t&nbsp;o&nbsp;&nbsp;&nbsp;t&nbsp;h&nbsp;e&nbsp;&nbsp;&nbsp;V&nbsp;I&nbsp;M&nbsp;&nbsp;&nbsp;T&nbsp;u&nbsp;t&nbsp;o&nbsp;r&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;&nbsp;Version&nbsp;1.4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=</code><br>
<code>===============================================================================</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vim&nbsp;is&nbsp;a&nbsp;very&nbsp;powerful&nbsp;editor&nbsp;that&nbsp;has&nbsp;many&nbsp;commands,&nbsp;too&nbsp;many&nbsp;to</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;explain&nbsp;in&nbsp;a&nbsp;tutor&nbsp;such&nbsp;as&nbsp;this.&nbsp;&nbsp;This&nbsp;tutor&nbsp;is&nbsp;designed&nbsp;to&nbsp;describe</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enough&nbsp;of&nbsp;the&nbsp;commands&nbsp;that&nbsp;you&nbsp;will&nbsp;be&nbsp;able&nbsp;to&nbsp;easily&nbsp;use&nbsp;Vim&nbsp;as</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;an&nbsp;all-purpose&nbsp;editor.</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;approximate&nbsp;time&nbsp;required&nbsp;to&nbsp;complete&nbsp;the&nbsp;tutor&nbsp;is&nbsp;25-30&nbsp;minutes,</code><br>
</FONT></TD></TR></TABLE><P>

<P>
You are supposed to edit the <TT>
<FONT COLOR="#0000ff">tutor</FONT></TT> file itself as practice,
following through 6 lessons. Copy it first to your home
directory.

<P>
Table <A HREF="node9.html#table:vimcommands">6.1</A> is a quick reference for <TT>
<FONT COLOR="#0000ff">vi</FONT></TT>.
It contains only a few of the many hundreds of available commands
but is enough to do all basic editing operations.
Take note of the following:

<UL>
<LI><TT>
<FONT COLOR="#0000ff">vi</FONT></TT> has several <I>modes</I> of operation. If you press
<IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-I.png" ALT="I">, you enter <I>insert</I>-mode. You then enter
text as you would in a normal DOS text editor, <I>but you
cannot arbitrarily move the cursor and delete characters while
in insert mode</I>. Pressing <IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-esc.png" ALT="Esc"> will get
you out of insert mode, where you are not able to insert
characters, but can now do things like arbitrary deletions and
moves.
</LI>
<LI>Pressing <IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-shift.png" ALT="Shift">-<IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-colon.png" ALT="Colon"> (i.e.,<I>&nbsp;&nbsp;:&nbsp;&nbsp;</I>) gets you into
<I>command-line</I> mode, where you can do operations like
importing files, saving of the current file, searches, and text processing.
Typically, you type <I>&nbsp;&nbsp;:&nbsp;&nbsp;</I> then some text, and then hit <IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-enter.png" ALT="Enter">.
</LI>
<LI>The word <I>register</I> is used below. A register is
a hidden clipboard.
</LI>
<LI>A useful tip is to enter <TT>
<FONT COLOR="#0000ff">:set ruler</FONT></TT> before doing
anything. This shows, in the bottom right corner of the screen,
what line and column you are on.
</LI>
</UL>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>

<P>

<P>
<A NAME="10350"></A>
<TABLE CELLPADDING=1 BORDER="1">
<CAPTION><STRONG>Table:</STRONG>
Common <TT>
<FONT COLOR="#0000ff">vi</FONT></TT> commands</CAPTION>
<TR><TD ALIGN="LEFT"><A NAME="table:vimcommands"></A><B>Key combination</B></TD>
<TH ALIGN="LEFT"><B>Function</B></TH>
</TR>
<TR><TD ALIGN="LEFT"><I>h</I>&nbsp;&nbsp;&nbsp;&nbsp; <I>or</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-leftarrow.png" ALT="Left Arrow"></TD>
<TD ALIGN="LEFT">Cursor left</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>l</I>&nbsp;&nbsp;&nbsp;&nbsp; <I>or</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-rightarrow.png" ALT="Right Arrow"></TD>
<TD ALIGN="LEFT">Cursor right.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>k</I>&nbsp;&nbsp;&nbsp;&nbsp; <I>or</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-uparrow.png" ALT="Up Arrow"></TD>
<TD ALIGN="LEFT">Cursor up.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>j</I>&nbsp;&nbsp;&nbsp;&nbsp; <I>or</I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-downarrow.png" ALT="Down Arrow"></TD>
<TD ALIGN="LEFT">Cursor down.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>b</I></TD>
<TD ALIGN="LEFT">Cursor left one word.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>w</I></TD>
<TD ALIGN="LEFT">Cursor right one word.</TD>
</TR>
<TR><TH ALIGN="LEFT"><B><TT>&#123;</TT></B></TH>
<TD ALIGN="LEFT">Cursor up one paragraph.</TD>
</TR>
<TR><TH ALIGN="LEFT"><B><TT>&#125;</TT></B></TH>
<TD ALIGN="LEFT">Cursor down one paragraph.</TD>
</TR>
<TR><TH ALIGN="LEFT"><B><TT>&#94;</TT></B></TH>
<TD ALIGN="LEFT">Cursor to line start.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>$</I></TD>
<TD ALIGN="LEFT">Cursor to line end.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>gg</I></TD>
<TD ALIGN="LEFT">Cursor to first line.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>G</I></TD>
<TD ALIGN="LEFT">Cursor to last line.</TD>
</TR>
<TR><TD ALIGN="LEFT"><IMG ALIGN=ABSMIDDLE BORDER=0 SRC="key-esc.png" ALT="Esc"></TD>
<TD ALIGN="LEFT">Get out of current mode.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>i</I></TD>
<TD ALIGN="LEFT">Start insert mode.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>o</I></TD>
<TD ALIGN="LEFT">Insert a blank line below the current line and then start insert mode.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>O</I></TD>
<TD ALIGN="LEFT">Insert a blank line above the current line and then start insert mode.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>a</I></TD>
<TD ALIGN="LEFT">Append (start insert mode after the current character).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>R</I></TD>
<TD ALIGN="LEFT">Replace (start insert mode with overwrite).</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:wq</FONT></TT></TD>
<TD ALIGN="LEFT">Save (write) and quit.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:q</FONT></TT></TD>
<TD ALIGN="LEFT">Quit.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:q!</FONT></TT></TD>
<TD ALIGN="LEFT">Quit forced (without checking whether a save is required).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>x</I></TD>
<TD ALIGN="LEFT">Delete (delete under cursor and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>X</I></TD>
<TD ALIGN="LEFT">Backspace (delete left of cursor and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>dd</I></TD>
<TD ALIGN="LEFT">Delete line (and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:j!</FONT></TT></TD>
<TD ALIGN="LEFT">Join line (remove newline at end of current line).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>Ctrl-J</I></TD>
<TD ALIGN="LEFT">Same.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>u</I></TD>
<TD ALIGN="LEFT">Undo.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>Ctrl-R</I></TD>
<TD ALIGN="LEFT">Redo.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>de</I></TD>
<TD ALIGN="LEFT">Delete to word end (and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>db</I></TD>
<TD ALIGN="LEFT">Delete to word start (and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>d$</I></TD>
<TD ALIGN="LEFT">Delete to line end (and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>d</I><B><TT>&#94;</TT></B></TD>
<TD ALIGN="LEFT">Delete to line beginning (and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>dd</I></TD>
<TD ALIGN="LEFT">Delete current line (and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>2dd</I></TD>
<TD ALIGN="LEFT">Delete two lines (and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>5dd</I></TD>
<TD ALIGN="LEFT">Delete five lines (and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>p</I></TD>
<TD ALIGN="LEFT">Paste clipboard (insert register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>Ctrl-G</I></TD>
<TD ALIGN="LEFT">Show cursor position.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>5G</I></TD>
<TD ALIGN="LEFT">Cursor to line five.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>16G</I></TD>
<TD ALIGN="LEFT">Cursor to line sixteen.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>G</I></TD>
<TD ALIGN="LEFT">Cursor to last line.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">/</FONT></TT><I>search-string</I></TD>
<TD ALIGN="LEFT">Search forwards for <I>search-string</I>.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">?</FONT></TT><I>search-string</I></TD>
<TD ALIGN="LEFT">Search backwards for <I>search-string</I>.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:-1,$s/</FONT></TT><I>search-string</I><TT>
<FONT COLOR="#0000ff">/</FONT></TT><I>replace-string</I><TT>
<FONT COLOR="#0000ff">/gc</FONT></TT></TD>
<TD ALIGN="LEFT">Search and replace with confirmation starting
                                 at current line.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:,$s/</FONT></TT><I>search-string</I><TT>
<FONT COLOR="#0000ff">/</FONT></TT><I>replace-string</I><TT>
<FONT COLOR="#0000ff">/gc</FONT></TT></TD>
<TD ALIGN="LEFT">Search and replace with confirmation starting
                                 at line below cursor.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:,$s/&#92;&#60;</FONT></TT><I>search-string</I><TT>
<FONT COLOR="#0000ff">&#92;&#62;/</FONT></TT><I>replace-string</I><TT>
<FONT COLOR="#0000ff">/gc</FONT></TT></TD>
<TD ALIGN="LEFT">Search and replace whole words.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:8,22s/</FONT></TT><I>search-string</I><TT>
<FONT COLOR="#0000ff">/</FONT></TT><I>replace-string</I><TT>
<FONT COLOR="#0000ff">/g</FONT></TT></TD>
<TD ALIGN="LEFT">Search and replace in lines 8 through 22 without
                               confirmation.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:%s/</FONT></TT><I>search-string</I><TT>
<FONT COLOR="#0000ff">/</FONT></TT><I>replace-string</I><TT>
<FONT COLOR="#0000ff">/g</FONT></TT></TD>
<TD ALIGN="LEFT">Search and replace whole file without confirmation.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:w</FONT></TT> <I>filename</I></TD>
<TD ALIGN="LEFT">Save to file <I>filename</I>.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:5,20w</FONT></TT> <I>filename</I></TD>
<TD ALIGN="LEFT">Save lines 5 through 20 to file <I>filename</I> (use Ctrl-G
                                 to get line numbers if needed).</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:5,$w!</FONT></TT> <I>filename</I></TD>
<TD ALIGN="LEFT">Force save lines 5 through to last line to file <I>filename</I>.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:r</FONT></TT> <I>filename</I></TD>
<TD ALIGN="LEFT">Insert file <I>filename</I>.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>v</I></TD>
<TD ALIGN="LEFT">Visual mode (start highlighting).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>y</I></TD>
<TD ALIGN="LEFT">Copy highlighted text to register.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>d</I></TD>
<TD ALIGN="LEFT">Delete highlighted text (and copy to register).</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>p</I></TD>
<TD ALIGN="LEFT">Paste clipboard (insert register).</TD>
</TR>
<TR><TD ALIGN="LEFT">Press <I>v</I>, then move cursor</TD>
<TD ALIGN="LEFT">Search and replace within</TD>
</TR>
<TR><TD ALIGN="LEFT">down a few lines, then,</TD>
<TD ALIGN="LEFT">highlighted text.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:s/</FONT></TT><I>search-string</I><TT>
<FONT COLOR="#0000ff">/</FONT></TT><I>replace-string</I><TT>
<FONT COLOR="#0000ff">/g</FONT></TT></TD>
<TD ALIGN="LEFT">&nbsp;</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:help</FONT></TT></TD>
<TD ALIGN="LEFT">Reference manual (open new window with help screen
                                 inside--probably the most important command here!).</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:new</FONT></TT></TD>
<TD ALIGN="LEFT">Open new blank window.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:split</FONT></TT> <I>filename</I></TD>
<TD ALIGN="LEFT">Open new window with <I>filename</I>.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:q</FONT></TT></TD>
<TD ALIGN="LEFT">Close current window.</TD>
</TR>
<TR><TD ALIGN="LEFT"><TT>
<FONT COLOR="#0000ff">:qa</FONT></TT></TD>
<TD ALIGN="LEFT">Close all windows.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>Ctrl-W j</I></TD>
<TD ALIGN="LEFT">Move cursor to window below.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>Ctrl-W k</I></TD>
<TD ALIGN="LEFT">Move cursor to window above.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>Ctrl-W -</I></TD>
<TD ALIGN="LEFT">Make window smaller.</TD>
</TR>
<TR><TD ALIGN="LEFT"><I>Ctrl-W +</I></TD>
<TD ALIGN="LEFT">Make window larger.</TD>
</TR>
</TABLE>

<P>

<H1><A NAME="SECTION00920000000000000000">
6.2 Syntax Highlighting</A>
</H1>

<P>
Something all U<SMALL>NIX</SMALL> users are used to (and have come to
expect) is <I>syntax highlighting</I>. This basically means that
a <TT>
<FONT COLOR="#0000ff">bash</FONT></TT> (explained later) script will look like:

<P>
&nbsp;  <!-- MATH
 $\epsfbox{with-syntax.ps}$
 -->
<IMG
 WIDTH="224" HEIGHT="79" ALIGN="BOTTOM" BORDER="0"
 SRC="img15.png"
 ALT="\epsfbox{with-syntax.ps}"> &nbsp;&nbsp; instead of &nbsp;&nbsp;
 <!-- MATH
 $\epsfbox{without-syntax.ps}$
 -->
<IMG
 WIDTH="225" HEIGHT="79" ALIGN="BOTTOM" BORDER="0"
 SRC="img16.png"
 ALT="\epsfbox{without-syntax.ps}">

<P>
Syntax highlighting is meant to preempt programming errors by
colorizing correct keywords. You can set syntax highlighting in
<TT>
<FONT COLOR="#0000ff">vim</FONT></TT> by using <TT>
<FONT COLOR="#0000ff">:syntax on</FONT></TT> (but not in <TT>
<FONT COLOR="#0000ff">vi</FONT></TT>). Enable
syntax highlighting whenever possible--all good text editors
support it.

<P>

<H1><A NAME="SECTION00930000000000000000">
6.3 Editors</A>
</H1>

<P>
Although U<SMALL>NIX</SMALL> has had full graphics capability for a long time now, most administration
of low-level services still takes place inside text configuration files. Word
processing is also best accomplished with typesetting systems that require creation
of ordinary text files.  <FONT COLOR="#ffa500">[This is in spite of all the hype regarding the
WYSIWYG (what you see is what you get) word processor. This document itself
was typeset with L<SUP><SMALL>A</SMALL></SUP>T<SMALL>E</SMALL>X and the Cooledit text editor.]</FONT>
<P>
Historically, the standard text editor used to be <TT>
<FONT COLOR="#0000ff">ed</FONT></TT>.
<TT>
<FONT COLOR="#0000ff">ed</FONT></TT> allows the user to see only one line of text of a file at
a time (primitive by today's standards). Today, <TT>
<FONT COLOR="#0000ff">ed</FONT></TT> is
mostly used in its streaming version, <TT>
<FONT COLOR="#0000ff">sed</FONT></TT>. <TT>
<FONT COLOR="#0000ff">ed</FONT></TT> has
long since been superseded by <TT>
<FONT COLOR="#0000ff">vi</FONT></TT>.

<P>
The editor is the place you will probably spend most of your
time. Whether you are doing word processing, creating web
pages, programming, or administrating. It is your primary
interactive application.

<P>

<H2><A NAME="SECTION00931000000000000000">
6.3.1 Cooledit</A>
</H2>

<P>
(Read this if you ``just-want-to-open-a-file-and-start-typing-like-under-Windows.'')

<P>
<TT>
<FONT COLOR="#0000ff">cooledit</FONT></TT>
The best editor for day-to-day work is Cooledit, <FONT COLOR="#ffa500">[As
Cooledit's author, I am probably biased in this view.]</FONT> available
from <EM>the Cooledit web page</EM> <I>&lt;<TT><A NAME="tex2html9"
  HREF="http://cooledit.sourceforge.net/">http://cooledit.sourceforge.net/</A></TT>&gt;</I>.
Cooledit is a graphical (runs under X) editor. It is also a
full-featured Integrated Development Environment (IDE) for
whatever you may be doing. Those considering buying an IDE
for development need look no further than installing Cooledit for
free.

<P>
People coming from a Windows background will find Cooledit the
easiest and most powerful editor to use. It requires no tutelage;
just enter <TT>
<FONT COLOR="#0000ff">cooledit</FONT></TT> under X and start typing. Its
counterpart in text mode is <TT>
<FONT COLOR="#0000ff">mcedit</FONT></TT>, which comes with the
GNU Midnight Commander package <TT>
<FONT COLOR="#0000ff">mc</FONT></TT>. The text-mode
version is inferior to other text mode editors like <TT>
<FONT COLOR="#0000ff">emacs</FONT></TT>
and <TT>
<FONT COLOR="#0000ff">jed</FONT></TT>  but is adequate if you don't spend a lot of time in
text mode.

<P>
Cooledit has pull-down menus and intuitive keys. It is not
necessary to read any documentation before using Cooledit.

<P>

<H2><A NAME="SECTION00932000000000000000">
6.3.2 <TT>
<FONT COLOR="#0000ff">vi</FONT></TT> and <TT>
<FONT COLOR="#0000ff">vim</FONT></TT></A>
</H2>

<P>
Today <TT>
<FONT COLOR="#0000ff">vi</FONT></TT> is considered the standard. It is the only editor
that <I>will</I> be installed by default on <I>any</I> U<SMALL>NIX</SMALL>
system. <TT>
<FONT COLOR="#0000ff">vim</FONT></TT> is a
``Charityware'' version that (as usual)
improves upon the original <TT>
<FONT COLOR="#0000ff">vi</FONT></TT> with a host of features. It
is important to learn the basics of <TT>
<FONT COLOR="#0000ff">vi</FONT></TT> even if your day-to-day
editor is not going to be <TT>
<FONT COLOR="#0000ff">vi</FONT></TT>. The reason is that every
administrator is bound to one day have to edit a text file over
some really slow network link and <TT>
<FONT COLOR="#0000ff">vi</FONT></TT> is the best for this.

<P>
On the other hand, new users will probably find <TT>
<FONT COLOR="#0000ff">vi</FONT></TT>
unintuitive and tedious and will spend a lot of time learning and
remembering how to do all the things they need to. I myself
cringe at the thought of <TT>
<FONT COLOR="#0000ff">vi</FONT></TT> pundits recommending it to
new U<SMALL>NIX</SMALL> users.

<P>
In defense of <TT>
<FONT COLOR="#0000ff">vi</FONT></TT>, it should be said that many people use it
exclusively, and it is probably the only editor that really can do
absolutely <I>everything</I>. It is also one of the few editors
that has working versions and consistent behavior across all
U<SMALL>NIX</SMALL> and non-U<SMALL>NIX</SMALL> systems. <TT>
<FONT COLOR="#0000ff">vim</FONT></TT>
works on AmigaOS,
AtariMiNT, BeOS, DOS,
MacOS, OS/2, RiscOS, VMS, and
Windows (95/98/NT4/NT5/2000) as well as all U<SMALL>NIX</SMALL> variants.

<P>

<H2><A NAME="SECTION00933000000000000000">
6.3.3 Emacs</A>
</H2>

<P>
Emacs stands for Editor MACroS. It is the monster of all editors
and can do almost everything one could imagine that a single software
package might. It has become a de facto standard
alongside <TT>
<FONT COLOR="#0000ff">vi</FONT></TT>.

<P>
Emacs is more than just a text editor. It is a complete system of using a
computer for development, communications, file management, and things you
wouldn't even imagine there are programs for. There is even an <B>X</B>
Window System version available which can browse the web.

<P>

<H2><A NAME="SECTION00934000000000000000">
6.3.4 Other editors</A>
</H2>

<P>
Other editors to watch out for are <TT>
<FONT COLOR="#0000ff">joe</FONT></TT>, <TT>
<FONT COLOR="#0000ff">jed</FONT></TT>,
<TT>
<FONT COLOR="#0000ff">nedit</FONT></TT>, <TT>
<FONT COLOR="#0000ff">pico</FONT></TT>,
<TT>
<FONT COLOR="#0000ff">nano</FONT></TT>, and many others that try to emulate the
look and feel of well-known DOS, Windows, or Apple Mac
development environments, or to bring better interfaces by using
Gtk/Gnome or Qt/KDE.
The list gets longer each time I look. In
short, don't think that the text editors that your vendor has
chosen to put on your CD are the best or only free ones out
there. The same goes for other applications.

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html1832"
  HREF="node10.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html1828"
  HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html1822"
  HREF="node8.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html1830"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
<BR>
<B> Next:</B> <A NAME="tex2html1833"
  HREF="node10.html">7. Shell Scripting</A>
<B> Up:</B> <A NAME="tex2html1829"
  HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html1823"
  HREF="node8.html">5. Regular Expressions</A>
 &nbsp <B>  <A NAME="tex2html1831"
  HREF="node1.html">Contents</A></B> 
<!--End of Navigation Panel-->

</BODY>
</HTML>