home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
editor
/
ws_train.arc
/
EX6.WS
< prev
next >
Wrap
Text File
|
1986-09-15
|
7KB
|
163 lines
EXERCISE 6: SEARCHING AND REPLACING
Iε thi≤ exercise¼ yo⌡ wil∞ learε ho≈ t∩ searcΦ througΦ ß ì
documen⌠ fo≥ ß specifieΣ worΣ o≥ othe≥ strinτ oµ characters« A≤ ì
yo⌡ migh⌠ guess¼ tha⌠ i≤ ver∙ hand∙ wheε yo⌡ arσ doinτ ì
corrections¼ anΣ wan⌠ t∩ ski≡ quickl∙ t∩ thσ nex⌠ erro≥ iε thσ ì
documen⌠ withou⌠ scrollinτ t∩ it«
Iε additioε t∩ jus⌠ searchinτ fo≥ ß word¼ thσ prograφ caε ì
searcΦ fo≥ ß worΣ anΣ theε replacσ i⌠ witΦ another« Tha⌠ i≤ ì
hand∙ fo≥ sucΦ thing≤ a≤ correctinτ systematiπ spellinτ o≥ ì
capitalization error≤ o≥ fo≥ expandinτ abbreviations«
BotΦ simplσ searchinτ anΣ searchinτ witΦ replacemen⌠ arσ ì
usefu∞ fo≥ completinτ pre-writteε skeletoε documents.
SEARCHING
Let'≤ star⌠ witΦ thσ simplσ searcΦ command¼ Ctrl-q-f« Wheε ì
yo⌡ givσ thi≤ command¼ thσ prograφ prompt≤ you¼ askinτ wha⌠ yo⌡ ì
wisΦ t∩ searcΦ for« Yo⌡ theε ente≥ thσ worΣ o≥ othe≥ characte≥ ì
strinτ tha⌠ yo⌡ arσ lookinτ fo≥ anΣ arσ askeΣ choosσ froφ severa∞ ì
options« Thσ firs⌠ timσ yo⌡ tr∙ it¼ jus⌠ hi⌠ "Enteró agaiε wheε ì
askeΣ fo≥ options.
Okay¼ no≈ tr∙ it (read through the instructions first):
1. First¼ movσ thσ curso≥ t∩ thσ star⌠ oµ thi≤ screenful∞ ì
áááááááááb∙ hittinτ thσ "Homeó key.
ááááá2. Now give the search command Ctrl-q-f.
3« Wheε askeΣ wha⌠ yo⌡ wan⌠ t∩ find¼ typσ: hoho« ì
ááááá ááá(use lower case letters, the program is picky).
ááááá4« Remembe≥ t∩ jus⌠ hi⌠ thσ "Enteró ke∙ wheε askeΣ fo≥ ì
ááááá options.
5. Thσ curso≥ wil∞ jum≡ straigh⌠ t∩ thσ worΣ "hoho.ó Iµ ì
áááááááááyo⌡ don'⌠ seσ wha⌠ i≤ happening¼ tr∙ i⌠ again¼ theε ì
ááááááááácontinuσ readinτ thσ exercise.
What happened when you searched for the word "hoho?" (1)
Where did the search begin? (2)
REPEATING A SEARCH
Oncσ thσ character≤ yo⌡ arσ searchinτ fo≥ havσ beeε ì
specified¼ yo⌡ caε repea⌠ thσ searcΦ witΦ ß simplσ Ctrl-∞ ì
command« Sincσ wσ havσ alread∙ specifieΣ thσ worΣ "hohoó a≤ ou≥ ì
searcΦ pattern¼ movσ thσ curso≥ t∩ beginninτ oµ thi≤ paragraph¼ ì
anΣ hi⌠ Ctr-∞ ß fe≈ times.
hoho hoho hoho hoho hoho hoho hoho hoho hoho è hoho hoho hoho hoho hoho hoho hoho hoho hoho
A≤ yo⌡ see¼ eacΦ subsequen⌠ Ctrl-∞ move≤ thσ curso≥ t∩ thσ ì
nex⌠ occurrencσ oµ thσ worΣ "hoho."
NOT JUST WHOLE WORDS
Yo⌡ arσ no⌠ restricteΣ t∩ searche≤ fo≥ wholσ words« I⌠ i≤ ì
possiblσ t∩ searcΦ fo≥ an∙ combinatioε oµ characters« Fo≥ ì
instance¼ wha⌠ happen≤ iµ yo⌡ movσ thσ curso≥ t∩ thσ beginninτ oµ ì
thi≤ paragrapΦ theε initiatσ ß searcΦ fo≥ thσ strinτ "σ s"« (3)
SORRY, NO MATCH
A⌠ time≤ yo⌡ wil∞ givσ ß commanΣ t∩ searcΦ fo≥ ß certaiε ì
word¼ bu⌠ i⌠ wil∞ no⌠ bσ found« Fo≥ instance¼ yo⌡ wil∞ bσ glaΣ ì
t∩ hea≥ tha⌠ therσ arσ n∩ morσ "hohosó iε thi≤ exercise« Wha⌠ ì
woulΣ happeε iµ yo⌡ placeΣ thσ curso≥ a⌠ thσ enΣ oµ thi≤ ì
paragrapΦ anΣ gavσ thσ commanΣ t∩ searcΦ fo≥ tha⌠ word┐ (4⌐ Tr∙ ì
i⌠ anΣ seσ wha⌠ happens¼ theε returε t∩ thi≤ poin⌠ anΣ continuσ ì
thσ exercise.
REPLACEMENT
A≤ mentioneΣ above¼ yo⌡ caε specif∙ ß worΣ o≥ strinτ oµ ì
character≤ t∩ bσ substituteΣ fo≥ thσ searcΦ strinτ wheε i⌠ i≤ ì
found« Thσ commanΣ fo≥ searchinτ witΦ replacemen⌠ i≤ Ctrl-q-a« ì
Wheε yo⌡ hi⌠ Ctrl-q-a¼ yo⌡ arσ askeΣ fo≥ ß botΦ searcΦ patterε ì
anΣ ß replacement.
Wheε ß matcΦ i≤ found¼ thσ prograφ stop≤ anΣ ask≤ yo⌡ t∩ ì
verif∙ tha⌠ yo⌡ wan⌠ thσ replacemen⌠ t∩ bσ made« (Thσ promp⌠ ì
appear≤ a⌠ thσ righ⌠ sidσ oµ thσ to≡ linσ oε thσ screen).
M∙ namσ i≤ iε thσ sentencσ followinτ thi≤ paragraph« Usσ ì
thσ Ctrl-q-ß commanΣ t∩ replacσ i⌠ witΦ yours« Don'⌠ forge⌠ t∩ ì
capitalizσ thσ firs⌠ lette≥ oµ m∙ name¼ o≥ thσ searcΦ won'⌠ matcΦ ì
exactly¼ and¼ again¼ jus⌠ hi⌠ "Enteró wheε askeΣ fo≥ options«
My name is Larry.
MULTIPLE REPLACEMENT
A≤ yo⌡ migh⌠ guess¼ thσ repea⌠ command¼ Ctrl-l¼ caε bσ useΣ ì
t∩ repea⌠ searche≤ witΦ replacemen⌠ a≤ wel∞ a≤ simplσ searches« ì
Movσ thσ curso≥ t∩ thσ beginninτ oµ thi≤ paragrapΦ anΣ hi⌠ Ctrl-∞ ì
ß fe≈ times« Don'⌠ forge⌠ tha⌠ yo⌡ wil∞ havσ t∩ authorizσ eacΦ ì
replacemen⌠ oµ m∙ namσ wheε i⌠ i≤ found.
Larry Larry Larry Larry Larry Larry Larry Larry
THE OPTIONS
A≤ yo⌡ havσ noticed¼ severa∞ option≤ arσ availablσ wheneve≥ ì
yo⌡ givσ thσ searcΦ o≥ searcΦ anΣ replacσ commands« Iµ yo⌡ hi⌠ ìèthσ "?ó wheε prompteΣ fo≥ aε option¼ the∙ arσ explained¼ a≤ ì
follows:
b - search backward from the cursor position, not forward
áááááw - search for whole words only
áááááu - ignore cases of letters
áááááε - replacσ automatically¼ withou⌠ askinτ thσ questioε ì
ááááá ááREPLAC┼ Y/N?
ááááág - replace in the entire file, not just the first match
Yo⌡ caε als∩ ente≥ ß number« A≤ yo⌡ wil∞ seσ below¼ thσ ì
meaninτ oµ thσ numbe≥ optioε i≤ differen⌠ dependinτ upoε whethe≥ ì
i⌠ i≤ useΣ witΦ thσ simplσ searcΦ commanΣ o≥ thσ searcΦ anΣ ì
replace.
TRYING THE OPTIONS OUT
Try using these options a little --
M∙ namσ i≤ Larry« Wha⌠ happen≤ iµ yo⌡ searcΦ thi≤ paragrapΦ ì
fo≥ thσ worΣ "larryó witΦ thσ "uó optioε selected┐ (5)
Wha⌠ happen≤ iµ yo⌡ searcΦ fo≥ m∙ namσ startinτ a⌠ thi≤ ì
paragrapΦ witΦ thσ "bó optioε selected┐ (6⌐ Wha⌠ iµ yo⌡ theε ì
repea⌠ thσ searcΦ severa∞ time≤ usinτ Ctrl-l┐ (7)
Mos⌠ oµ thσ option≤ havσ thσ samσ meaninτ whethe≥ useΣ iε ß ì
simplσ search¼ Ctrl-q-f¼ o≥ ß searcΦ witΦ replacement¼ Ctrl-q-a« ì
However¼ thσ optioε wherσ yo⌡ specif∙ ß numbe≥ differs« If¼ fo≥ ì
example¼ yo⌡ specif∙ thσ numbe≥ │ a≤ aε optioε witΦ ß simplσ ì
search¼ thσ thirΣ occurrencσ oµ thσ searcΦ worΣ wil∞ bσ ì
found¼ no⌠ thσ first« Thσ numbe≥ optioε ha≤ ß differen⌠ ì
meaninτ witΦ thσ searcΦ anΣ replacσ command« Caε yo⌡ figurσ ì
ou⌠ wha⌠ i⌠ is┐ (8)
Wha⌠ happen≤ iµ yo⌡ tr∙ t∩ combinσ options┐ Fo≥ instancσ ì
wha⌠ happen≤ iµ yo⌡ selec⌠ botΦ "bó anΣ "u?ó (9⌐
RECAPPING
Yo⌡ caε searcΦ througΦ ß documen⌠ fo≥ ß specifieΣ worΣ o≥ ì
characte≥ pattern« Yo⌡ caε als∩ replacσ thσ specifieΣ patterε ì
witΦ somσ othe≥ character≤ wheε i⌠ i≤ found« Therσ i≤ ß third¼ ì
related¼ commanΣ whicΦ repeat≤ thσ las⌠ searcΦ o≥ searcΦ witΦ ì
replacement.
The three commands we learned were:
Ctrl-q-f
ááááááááááCtrl-q-a
ááááááááááCtrl-l
Iε addition¼ severa∞ option≤ o≥ modifier≤ arσ availablσ fo≥ ì
thσ searcΦ anΣ searcΦ anΣ replacσ commands« The∙ arσ b¼ w¼ u¼ n¼ ì
g¼ anΣ an∙ number« Thesσ option≤ ma∙ bσ combineΣ a⌠ will.