Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim - Scroll Below the End of the Document

Tags:

vim

When we edit the last few lines of a document in vim, those lines are displayed at the bottom part of the screen, which is a little uncomfortable for me. Is there a way to scroll below the end of the document, so that the bottom lines in the document can be displayed at the top of the screen? (Currently Sublime Text has such capability.)

I've done some searches, the closest answer I could find is to use "set scrolloff=10". But that is not what I am looking for. Since it doesn't display the bottom lines of the document at the top of the screen.

Thanks in advance!

like image 483
Yixing Avatar asked Mar 09 '14 15:03

Yixing


People also ask

How do I scroll down in vi?

To move right, press l . To move down, press j . To move up, press k .

How to move cursor to end of file in Vim?

You can jump to line number 700 (press ESC type 700G) 700G Move cursor to end of file in vim In short press the Esc key and then press Shift + G to move cursor to end of file in vi or vim text editor under Linux and Unix-like systems.

How to jump to the end of a file in Vim?

Hit Esc + A + $ : Go to bottom of the file and end of line. In this quick tutorial, you learned how to move to the last character of the file. Now you know how to jump to the end of the file using the vim command. We also explained how to jump to the start of the file using the vim text editor, including various keyboard shortcuts combinations.

How many lines does Vim scroll by default?

By default Vim scrolls three lines when moving vertically, and six columns when moving horizontally. On MS-Windows system-wide settings. Note that horizontal scrolling only works if 'nowrap' is set. Also, unless how the horizontal scrollbar works). You can modify the default behavior by mapping the keys.

How do I use a mouse scroll wheel with Vim?

When your mouse has a scroll wheel, it should work with Vim in the GUI. For the Win32 GUI the scroll action is hard coded. <ScrollWheelRight> . This should work in all modes, except when editing the command line. Note that horizontal scrolling only works if 'nowrap' is set.


Video Answer


1 Answers

In addition to @Kent's answer, zz would allow you to bring the current line to the middle of the screen, which in my opinion is more convenient to see the context of the current line of text/code.

Also, zb would bring the current line to the bottom of the screen, which may also help sometimes.

like image 198
albusshin Avatar answered Sep 28 '22 06:09

albusshin