5.3 Cursor Movement

   

To move the cursor, you must be in command mode. On most of the modern terminals, you can move the cursor with the arrow keys on your keyboard. If this is not possible with your keyboard, you can move your cursor using other commands, as mentioned in Table 5-1.

Table 5-1. Cursor Movement Commands
Command Effect
l Move one character right
h Move one character left
j Move one line down
k Move one line up
<space> Move one character right
G Go to last line of the file
nG Go to line number n in the file
$ Go to end of current line
^ Go to start of line
w Go to beginning of next word
b Go to beginning of previous word
e Move to end of word
H Go to first line of screen
M Go to middle line of screen
L Go to last line of screen
( Go to beginning of sentence
) Go to end of sentence
{ Go to beginning of paragraph
} Go to end of paragraph

Before using any of these commands, make sure that you are in the command mode by pressing the graphics/esc.gif key. The G command is used to go to a line number in the file. If you want to go to the start of the file, use 1G . To go to end of file, use G . To go to line number 100, use 100G . You can press graphics/ctrlg.gif at any time to find out which line you are on. You can also instruct the vi editor to display the line number with each line using the :set number command.

The start and end of a sentence are considered with reference to the dot "." character. The start and end of a paragraph are indicated with reference to a blank line. In other words, text within two blank lines is considered to be a paragraph.

We can combine vi commands. For example, $ is used to go to the end of a line, and G is used to go to the last line of the file. We can combine these two commands as $G to go to end of the last line of a file. Other commands can be combined in a similar fashion.


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net