Vim Go To Line with Different Ways – POFTUT

Vim Go To Line with Different Ways

Vim provides a lot of useful features and shortcuts during usage. In this tutorial we will look different ways to go specified line numbers or position in a file.

Show Line Numbers

In this tutorial we will learn navigating to the specified line in vim. But how can we specify line we want to go. We need line numbers. We are sure that counting line numbers one by one is not a good way especially in big files. So We need to show line numbers in vim. We can use : set number like below.

: set number
Show Line Numbers
Show Line Numbers

Go To Line with Command Line

Now most crucial part we will see different ways to go specified line. The simplest one is specifying line number as a vim command with :. In this example we will navigate to the 30 with the following command.

: 30

Go To Line with Shortcut

We can go to the specified line whiteout using command line. We will use shortcut for this operation. In this example we will go to the line 20.


Go To Line After Opening File

If we know the line number all ready before opening the file we can specify the line number as a parameter. We will go line number 45 after opening the file with the following command.

$ vim +45 main.c

End Of File

We can also simply go to the end of line without specifically providing the end line number. We can use G command like below.


Start Of File

There is different alternatives to go first line . Because know know the first line number we can simply say go line number 1. or other alternatives.

LEARN MORE  Linux Vi and Vim Command-Line Text Editor Tutorial

Go First Line with Line Number


Go First Line Keyboard shortcut


Leave a Comment