Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from Dec 24 '12 at 19:16

This question came from our site for professional and enthusiast programmers.

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
up vote 8 down vote accepted

You can either do:




in normal mode.

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

share|improve this answer
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

share|improve this answer

This is an alternative:


that works, too.

share|improve this answer

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

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .