I have typed gg to go to the beginning of the file in Vim. Now how can I directly go to a particular line such as 505?

  • 1
    Download this, print it and post it somewhere. – Burhan Khalid Dec 24 '12 at 11:54
  • In addition to all the fine answers below, may I suggest reading :help motion. – Michael Foukarakis Dec 24 '12 at 11:55

You can either do:




in normal mode.

Also, G, always in normal mode, gets you to the end of the file.

  • how would i enter command mode ? What is the basic difference between the two options that you mentioned ? – Geek Dec 24 '12 at 11:55
  • Well, you are in command mode by default when you edit a file. – fge Dec 24 '12 at 11:55
  • is Insert mode==command mode ? – Geek Dec 24 '12 at 11:56
  • No it isn't. In insertion mode, you enter text freely (by default, vim will display -- INSERT -- or -- REPLACE -- at the bottom of the window when you are in insert mode) and press Esc to get back to command mode. – fge Dec 24 '12 at 11:57
  • so that means command mode==normal mode right ? – Geek Dec 24 '12 at 12:01

just :505

and it jumps to line 505


This is an alternative:


that works, too.


Simply use :505 (or) vim file +505 command
To open file and go to line 505

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.