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.

Here's an answer I want about 5 times a day.

In vi, the command to go to the end of the file is G.

But that always leaves me at the start of the last line of the file, if files don't have a blank line at the end.

How can I jump to the end of the file and append a new blank line, so that I can just start typing?

Thanks!

share|improve this question
add comment

3 Answers

up vote 18 down vote accepted

What about Go, successively? ;-)

share|improve this answer
2  
Perfect, thank you! Easy to remember too :) –  Richard Jun 28 '11 at 11:28
    
@Richard Also check out the capital 'O' command if you aren't familiar with that one. It creates a new line above the current one and puts you in insert mode. –  Corey Jun 28 '11 at 16:38
add comment

One way to do this is to create a macro and place it in your .vimrc file.

map , GA<enter>

This will map the comma key. When pressed, vi will go to the end of the file, go to the end of that line and create a new blank line. This will also leave you in insert / edit mode.

share|improve this answer
1  
A<enter> ? o as suggested by @binfalse, is the right way! –  Benoit Jun 28 '11 at 14:06
add comment

An alternative with command line:

:$put _

If you want to understand that, you can also read this answer on registers

share|improve this answer
add comment

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.