DEV Community

Flávia Bastos
Flávia Bastos

Posted on • Originally published at on


Go to line number in a file using vim

You want to see line 3842 of file called and you can only access that file using vim. You open the file and to your dismay, by default, vim doesn’t display line numbers. Here are your options:

  • Arrow down and hope you find that line before retirement
  • Display the line numbers by hitting : and typing set number. Now at least you can see the line numbers while you arrow down… (To remove line numbers, do: and type set nonumber)
  • Go directly to that line by using one of the following options:
    • hit : and type the line number and enter, in this case :3842 enter
    • type the line number and hit SHIFT+g

Note: if you hit SHIFT+g without typing the line number, you go to the end of the file.

BONUS: You can accomplish the same thing in VSCode by hitting CTRL+g, typing the line number and enter 🙂

The post _Go to line number in a file using vim was originally published at

Top comments (2)

jvanz profile image
José Guilherme Vanz

Nice tips! I did not know the SHIFT+g one. :)
Another option I used a lot is the vim +3842. Thus, vim open the file and jump directly to line I've specified in the command line. Thanks for you article!

flaviabastos profile image
Flávia Bastos

And I did not know about the option of opening on the line! Thanks for sharing!

An Animated Guide to Node.js Event Loop

>> Check out this classic DEV post <<