Javatpoint Logo
Javatpoint Logo

vi move around a file

In command mode, we can move to different parts of a file with h,j,k,l commands. These (h,j,k,l) keys are used because at the time of vi invention, arrow keys were not invented. Although, we can use arrow keys also. Arrow keys and h,j,k,l keys work same.

j

The j command works same as the downward arrow. You can move to the below lines.

Example:

Linux Vi Move1

Look at the above snapshot, letter e is repeated twice. To correct that we need to go to that line.

Linux Vi Move2

Look at the above snapshot, after pressing either j key or downward key, we moved to that line and corrected it.

k

The k command works same as the upward arrow. You can move to the above lines.

Example:

Linux Vi Move3

Look at the above snapshot, our cursor is at letter e and we want to move up at the blank line to write something.

Linux Vi Move4

Look at the above snapshot, after pressing either k key or upward key, we moved to the upper line and have written over there.

h

The h command works same as the leftward arrow. You can move in leftwards direction.

Example:

Linux Vi Move5

Look at the above snapshot, our cursor is at the end and we want to move to the starting of the second line.

Linux Vi Move6

Look at the above snapshot, after pressing either h key or leftward key, we're at starting of the second line.

l

The l command works same as the rightward arrow. You can move in rightwards direction.

Example:

Linux Vi Move7

Look at the above snapshot, we are at starting and we want to move to the end of the last line

Linux Vi Move8

Look at the above snapshot, after pressing either l key or rightward arrow, we're at the end of the last line.

Next TopicLinux vi jump




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA