Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I typed "gg" to go to the beginning of the file in VIM. Now how can I go to a particular line say "505" directly ?

share|improve this question

migrated from stackoverflow.com Dec 24 '12 at 19:16

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

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

5 Answers 5

up vote 8 down vote accepted

You can either do:

:<linenum>

or

<linenum>gg

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

This has taken me only few seconds to find it: link

share|improve this answer

just :505

and it jumps to line 505

share|improve this answer

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

share|improve this answer

This is an alternative:

505G

that works, too.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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