Cursors Movements

h: move the cursor one space to the left
j: move the cursor one space down
k: move the cursor one space up
l: move the cursor one space to the right

These commands may be repeated by holding the key down. Try moving around in your text now. If you attempt an impossible movement, e.g. pressing the letter k when the cursor is on the top line, the screen will flash, or the terminal will beep. Here are more movement commands.

w: move to the start of the next word
e: move to the end of the next word
E: move to the end of the next word before a space
b: move to the start of the previous word
0: move to the start of the line
^: move to the first word of the current line
$: move to the end of the line
<CR>: move to the start of the next line
-: move to the start of the previous line
G: move to the end of the file
1G: move to the start of the file
nG: move to line number n
<Cntl> G: display the current line number
%: to the matching bracket
H: top line of the screen
M: middle line of the screen
L: bottom of the screen
n|: more cursor to column n

To move the cursor a number of positions left.

nh: move the cursor n positions left

The commands that deal with lines use the modifier to refer to line numbers. The G is a good example.

1G: Move the cursor to the first line

has a large set of commands which can be used to move the cursor around the file. Single character movement through to direct line placement of the cursor. vi can also place the cursor at a selected line from the command line.

vi +10 myfile.tex

This command opens the file myfile.tex and places the cursor 10 lines down from the start of the file.

Try out some of the commands in this section. Very few people can remember all of them in one session. Most users use only a subset of the above commands.

Supported By

File Browser Reference
Department FHERIS
University of Galway
HEA Logo