How can I disable that vim lets me scroll past the end of a file?

link|improve this question
Resize your terminal so it only shows one line apart from any header. Then make sure to never open a zero-line file. – Eroen Jan 23 at 19:39
feedback

2 Answers

up vote 0 down vote accepted

Vim doesn't actually let you scroll past the end of the file (as in, move the cursor past the last existing line), but it shows you a few lines behind the last one, because it has to show something.

It cannot be disabled, sorry. Not unless you wish to download Vim's sources (it is open source, after all) and fiddle with it. It natively inserts ~'s on rows that don't exist, because, well, it has to show something. All editors do that.

As someone suggested, there are workarounds around this ... but that is all they are - workarounds. And none of them work really pretty. I wouldn't recommend any of them.

link|improve this answer
feedback

Without a fairly ugly hack that would probably look visually disturbing and slow Vim down, you can't do what you want. Basically you would have to set up something like an autocmd for the CursorMoved/CursorMovedI events that tried to detect whether the bottom of the file was displayed, and if so, execute some normal mode commands to force the scroll position.

It is worth noting (and as the people at link that johnny provided in his comment say), Vim is not the only application that behaves like this, and you can't really scroll past the end of a file in Vim—the last line must always be visible.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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