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.

38Chapter 2An Embarrassment of Riches: EditorsmyArraylist.doSomething(magical); // coolFrom the beginning of the line, you’d need to type w seven times (or knowto type 7w—but how could you guess seven?) To help out, vi uses the uppercaseW to skip words defined not by punctuati<strong>on</strong> but solely by white space.Think of it as “bigger” words. And of course B will go “back” by these biggerwords. So <strong>on</strong> our example line, a single W will get you to the start of thecomment.Be sure that you’re not just reading these descripti<strong>on</strong>s. Run vi <strong>on</strong> any filethat you can find and practice navigating by lines or words or screens. Onceyou get the hang of it, it can be so much faster than reaching for the mouse andtrying to maneuver the cursor into just the right spot between letters.Sometimes you can see where you want to go based <strong>on</strong> the characters oftext in the document. See that “x”? That’s a relatively rare character <strong>on</strong> any lineof text. If you see a character, your cursor can “find” it if you type f and thenthe character you are looking for. So fx would search forward <strong>on</strong> the line foran “x”. And Fx would search backward from the cursor. To repeat the search,just type a semicol<strong>on</strong> (“;”).Searching for a string is another good way to move your way through afile. To search forward, type a slash (/), then the characters for which you wantto search, and end the string with a sec<strong>on</strong>d slash and then Enter: 2/myArrayList/To search backwards (towards the first line of the file) use the questi<strong>on</strong>mark rather than the slash to bracket your search string. In either case, to jumpto the next occurrence, type n, or 27n to jump to the 27th occurrence. Whetheryou are searching forward (/) or backward (?), using uppercase N will reversethe directi<strong>on</strong> as it searches for the next occurrence. So, you can search forwardwith /myVar/ and then press n for each next occurrence forward. If you go toofar, just type N to back up. Similarly, if you were going backwards looking foran occurrence of a c<strong>on</strong>structor, say something like: ?new HotClass?; theneach n will search toward the top of the file, and each N will search toward theend of file.2. The sec<strong>on</strong>d slash is opti<strong>on</strong>al in most vi implementati<strong>on</strong>s, but used for c<strong>on</strong>sistency with thesame command in ex mode which has opti<strong>on</strong>al suffix characters.

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

Saved successfully!

Ooh no, something went wrong!