Java Reference
In-Depth Information
L (“low”) moves to the bottom line of the window.
0 moves to the beginning of the line.
$ moves to the end of the line.
This may still be too slow for you, especially if you are working your way
through a large file. If you want to page up and down half a page at a time, try
^U and ^D (think “up” and “down”). To move a full page at each keystroke, try
^F and ^B (think “forward” and “back”).
This may still take a while, especially if you want to get to the absolute
beginning or end of the file. For those locations, type a three-character se-
quence, starting with a colon—which will jump your cursor to the status line
of the window—then type either zero or the dollar sign, then press the Enter
key. For example, :$ .
So what's with the colon? Just when you thought you were getting the
hang of the vi keystrokes, this odd pattern appears. It's called ex mode , and has
to do with the history of vi being built atop the ex editor. Typing the colon
got you back giving commands to ex , without the fancier screen-based
GUI. (Even editors can have command lines.) There are many powerful
search/replace commands that you can do from the ex command line; more on
that later. For now, though, remember that you can type the colon, then a line
number, then the Enter key and vi will position the cursor (and thus what is
displayed on the screen) to that line number. The 0 and $ are just special cases
of that more generic way to position your place in the file.
Back to our positioning in the file. Recall that h , j , k , and l will move you
one unit (char or line) at a time. Now enhance that motion by typing a number
first, then the h , j , k , or l . So to move five lines up type 5k (just be sure you
use a lowercase letter). You can move way down in a file by typing something
like 2000j which will move down 2,000 lines. If the file doesn't have that many
lines, you will find your cursor at the end of the file.
The point here is that almost any vi command can be preceded by a count,
to repeat it that many times.
A few more navigation tips. Another useful way to move through text is a
word at a time. You can move your cursor forward by a word with the letter w
(for “word”). You can move “back” with the letter b . You can move five words
at a time with 5w or 5b . See?
The definition of “word” to vi has to do with alphanumerics separated by
whitespace, but also by certain punctuation characters. So to vi , the following
Java code consists of how many words? Seven.
Search WWH ::




Custom Search