How can I get Eclipse to scroll past the bottom of the document?

EclipseConfigurationIdeEditor

Eclipse Problem Overview


When I scroll to the bottom of an open document in the Eclipse editor, the last line is at the bottom of the file. This is a tad annoying when editing code at the bottom of the file / screen.

How can I enable Eclipse to scroll (much like Vim or VS) down far enough that the last line of code reaches the top of the editor window?

I'm asking for the reverse of this question, in Eclipse: https://stackoverflow.com/questions/1747282/how-to-make-visual-studio-editor-stop-scrolling-past-bottom-of-a-file

Eclipse Solutions


Solution 1 - Eclipse

Considering the current implementation of a Scrollbar, this is not possible.
(See org.eclipse.swt.widgets.ScrollBar.java)

> At any given moment, a given scroll bar will have a single 'selection' that is considered to be its value, which is constrained to be within the range of values the scroll bar represents (that is, between its minimum and maximum values).

In the JDT (Java Editor) realm, the range is strongly linked to the number of lines a source file has.
Adding artificial "logical lines" to allows scrolling past the last line would have unintended consequences on many other parts of the JDT, related to displaying informations based on the line number of a source file (like a compilation error red underline).

This is also why there is no soft wrapping in those editors, despite a 7-years old bug 35779 (one of the most upvoted).

> Allowing word/soft wrap in the editor while typing is easy but not enough, a mapping between the model lines and the visual lines must be introduced to e.g. correctly show annotations.
It also introduces various problems that need to be solved, e.g. 'Go to Line': tools like a debugger, compiler etc. will report the model line but a user it will look strange that a different line will be selected than the one entered into the 'Go to Line' dialog

So for now, the SWT scrollbar example is still limited by the bottom of the window:

http://www.java2s.com/Code/JavaImages/ScrollBarExample.PNG

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMark McDonaldView Question on Stackoverflow
Solution 1 - EclipseVonCView Answer on Stackoverflow