Moving around a file
To move the cursor a single character in any direction,
use the arrow keys. Alternatively, if you are
in command mode, you can use the following keys:
h-
move left one character
l-
move right one character
k-
move up one line
j-
move down one line
You can also move around in larger units than a single character.
To repeat any of the following movement commands (that take an
optional parameter n)
type the number of times you wish the command to occur followed
by the command. For example,
to move right five words, enter 5w:
[n]b-
move back one (or n) words
[n]w-
move forward one (or n) words
^-
move to the start of the line
$-
move to the end of the line
[n](-
move back one (or n) sentences
[n])-
move forward one (or n) sentences
[n]{-
move back one (or n) paragraphs
[n]}-
move forward one (or n) paragraphs
(vi considers a sentence to be a sequence of characters
ending with a dot, question mark, or exclamation mark, followed by
either two spaces or a newline. Sentences begin on the first
nonwhitespace character following a preceding sentence, and are
delimited by paragraph and section delimiters. A paragraph is any
block of text delimited by empty lines or an nroff formatter
macro.)
Other commands control the portion of the file that the screen
displays:
<Ctrl>U-
move back half a screen
<Ctrl>D-
move forward half a screen
<Ctrl>B-
move back one screen
<Ctrl>F-
move forward one screen
You can specify line numbers to set your position within a file.
To discover the current line number, press <Ctrl>G.
A status line appears at the bottom of the screen, telling you the name
of the file, whether it has been modified, your current line number, the
number of lines in the file, and your position in the file as a
percentage of the length of the file. For example:
"soliloquy" [Modified] line 24 of 35 --68%--
To make line numbers appear at the left-hand side of the screen,
enter :set number (the numbers are not added to the
text of your file). To make vi always display line numbers,
you can add this command to your .exrc file.
See
``Configuring vi''
for more information.
The following commands move you to a specified line number:
#G-
go to line number #
1G-
go to the start of a file
G-
go to the end of a file (equivalent to $G)
For details of the many other movement commands available see
the
vi(C)
manual page.
Next topic:
Deleting and restoring text
Previous topic:
Saving files and quitting vi
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005