Javatpoint Logo
Javatpoint Logo

vi jump

When you move around a file you need to switch from one line to another line. Although you can do this with j,k keys or arrow keys. But when your file is too large, you can use G command. If you'll type a number before G then you'll be directed to the typed line number. And if you'll type only G then you'll be directed to the last line of the file.

One important command in vi editor is (``). it will help you to come back at the earlier position in the file. For example, if you are on line 4, by using 10G command you reach at line 10. But you forgot to edit something in line 4 and want to go back to line 4, here you can use `` which will redirect you to line 4.

nG

Here n denotes a number. You can type a number before G to jump to a particular line.

Example:

7G

Linux-vi-jump1

Look at the above snapshot, our cursor is at line 1 and we want to go to the line 7.

Linux-vi-jump2

Look at the above snapshot, in command mode after typing 7G (you'll not be able to see the typed command 7G on the screen), we're at 7th line.

G

If you'll not type any number before G, then you'll be directed to last line of the file.

Linux-vi-jump3

Look at the above snapshot, our cursor is at line 1.

Linux-vi-jump4

Look at the above snapshot, after pressing G, we're at the last line of the file.

``

This command allows us to move to the previous position in the file.

Example:

Linux-vi-jump5

Look at the above snapshot, we are at line number 9.

Linux-vi-jump6

Look at the above snapshot, we are at line 5 but forgot to write something on line 9.

Linux-vi-jump7

Look at the above snapshot, after typing `` we moved back to line 9.

Next TopicLinux vi delete




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA