Moving Around a File in vi

Usually, you can use the arrow keys on your keyboard to move around the open file in vi. In some cases, such as a very old or very minimal Linux installation, the arrow keys don't operate.

You can always move around your file using the key commands in Table 18-1.

Table 18-1. Commands for Moving Around in a File
KeyWhat It Does
jMoves cursor down one line.
kMoves cursor up one line.
lMoves cursor one character to the right.
hMoves cursor one character to the left.
GMoves cursor to the last line of the file.
LMoves cursor to the last line on the screen.
Ctrl-dMoves down one screen.
Ctrl-uMoves up one screen.
:nMoves the cursor to line n. For instance, :1 moves to the first line of the file.
$Moves to the end of the current line. ...

Get Spring Into Linux® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.