13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

42Chapter 2An Embarrassment of Riches: EditorsHere are a few more substituti<strong>on</strong> examples al<strong>on</strong>g with an explanati<strong>on</strong>for each..,$s/here/eternity/From here to the end of the file, replace here with eternity.27,$-5s/lost/found/From line 27 to the 5th line prior to the end of the file, replace lost withfound.s/here/now/Replace here with now, <strong>on</strong> the current line <strong>on</strong>ly.Each line that has a match will do the substituti<strong>on</strong> <strong>on</strong> <strong>on</strong>ly the first occurrenceof the string. If you want to change all occurrences <strong>on</strong> those lines, youappend a g (for “global” substituti<strong>on</strong>) to the end of the command. C<strong>on</strong>siderthis snippet of Java:class tryout{int tryout;tryout(int startval) { // make a new tryouttryout = startval;} // tryout c<strong>on</strong>structor// a tryout-like resettingpublic voidsetTryout(int toval) {tryout = toval;}// willfindtryoutinhere} // class tryout1,$s/tryout/sample/Works as expected except for line 5, where “tryout” appears as thec<strong>on</strong>structor name but also in the comment.1,$s/tryout/sample/gWorks better (note the trailing g). But neither command can deal with“Tryout” in the setTryout method name. That’s because of the uppercase“T”, which doesn’t match “tryout”.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!