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.

44Chapter 2An Embarrassment of Riches: EditorsTable 2.2 Some useful vi substituti<strong>on</strong>sCommand:1,$s/ *$//:1,$s/^.*$/""/:1,$s/^"//:1,$s/"$//Explanati<strong>on</strong>Removes all (any number of) trailing blanks—that is, looks for zero ormore blanks followed immediately by the end of line, and replacesthem with nothing (no characters between the last two slashes).Puts quotes around the text of each and every line.Removes the leading quote from any line that starts with <strong>on</strong>e.Removes the trailing quote from any line that ends with <strong>on</strong>e.There is so much more that could be said about regular expressi<strong>on</strong>s. Theyare <strong>on</strong>e of the most powerful features for making big changes with fewkeystrokes. It’s an integral part of sed, Perl, and other tools. It’s in such demandthat it has been added to Java for better pattern matching. See Secti<strong>on</strong> 2.6 forways to learn more about regular expressi<strong>on</strong>s.2.2.4 Starting Off Right: .exrcYou can preset certain behaviors in vi by putting ex commands in a file called.exrc in your home directory. Those commands will be read whenever youinvoke vi and before you begin typing commands.Here’s a simple but useful .exrc example:" set my favorite opti<strong>on</strong>s:set autoindent shiftwidth=4set ignorecaseAs you can see from the example, settings can be combined <strong>on</strong> <strong>on</strong>e line.Note also that these lines do not begin with a col<strong>on</strong>. A col<strong>on</strong> is needed if youtype these lines from within vi—because you need to get into ex mode; butsince these are assumed to be ex commands (hence the name .exrc) they aregoing straight to the ex side of vi and no col<strong>on</strong> is needed. Comment linesbegin with a double quote; the rest of the line is ignored, and doesn’t need amatching quote.The ignorecase command tells vi to ignore any difference betweenupper- and lowercase characters when searching for text with the / or ? commands.The single character searches <strong>on</strong> the current line (f and F) are not

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

Saved successfully!

Ooh no, something went wrong!