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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

40Chapter 2An Embarrassment of Riches: EditorsChange does the delete, then puts you in input mode. (Notice the reminder<strong>on</strong> the status line.) Remember, to get out of input mode and back intovi mode, press the Escape key.Sometimes you’ve d<strong>on</strong>e too much, and you’d like to undo what you’vejust d<strong>on</strong>e. Typing u will undo the last change that you made. But here’s a differencebetween the classic vi and some of the new, improved versi<strong>on</strong>s. In classicvi, if you type another u, then you are telling vi to undo what it justdid—which was an undo. So the undo of an undo remakes the change that youhad originally made. But in vim, “vi improved,” typing u again and again willjust keep undoing previous changes. If you want to undo the undo, in vim,you need to type :redo and then Enter.The vi editor has shortcuts for helping you to change the indentati<strong>on</strong> ofyour code. Typing two less-than signs () will shift the line to the right. Typing a numberfirst and then the less-than or greater-than signs will shift that many lines at<strong>on</strong>ce. But how far will they shift? The default is usually set at eight, but youcan set it to any value you want. In ex mode you can set all sorts of values andflags, customizing vi’s operati<strong>on</strong>. The value we’re interested in here isshiftwidth which can be abbreviated sw. So the command would be :setsw=4 if you want each shift to move by four characters. For more about this,and how to make it your default, see Secti<strong>on</strong> 2.2.4.Any command that you do may be worth repeating. Say, you just shifted14 lines and you’d like to shift them further. Or you just deleted five lines, andwould like to delete five more. Well, you could just retype the command, butan easier way is just to type the period (.) and let vi repeat it for you.2.2.1 ExitingThere are three ways of exiting vi (ZZ, :q, :q!) that you should know. Thecorrect <strong>on</strong>e to use depends <strong>on</strong> whether or not you want to save the changes tothe file and <strong>on</strong> whether or not you have saved your changes.• ZZ saves and quits in <strong>on</strong>e step (three keystrokes).• :w writes what you’ve been editing but doesn’t quit.• :w filename writes what you’ve been editing to a new file namedfilename; it will complain (and not write out anything) if the filealready exists.

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

Saved successfully!

Ooh no, something went wrong!