line = editor.getFirstVisibleLine()
end = editor.getLineEndPosition(line)
pos = editor.findColumn(line, editor.getColumn(editor.getCurrentPos()))
editor.gotoPos(min(pos, end))
if end < pos:
editor.lineEnd() # hack: gotoPos() doesn't change lineUp/lineDown target column
Cursor to bottom (Ctrl+Down)
line = editor.getFirstVisibleLine() + editor.linesOnScreen() - 1
end = editor.getLineEndPosition(line)
pos = editor.findColumn(line, editor.getColumn(editor.getCurrentPos()))
editor.gotoPos(min(pos, end))
if end < pos:
editor.lineEnd() # hack: gotoPos() doesn't change lineUp/lineDown target column
The keystrokes I've used were chosen based on this scheme: Right-Arrow moves forward one char, Ctrl+Right moves forward one word, so: Up-Arrow moves up one line, Ctrl+Up moves to top of window. (Maybe "top of paragraph" would be more semantically correct, but I don't really use "paragraph" as an organizing concept in my code.)
I've also assigned, per my own logic, Alt+Up to scroll up one line, so Ctrl+Alt+Up scrolls to the top.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I wrote a few small scripts to (a) move the cursor to the top/bottom of the window, and (b) scroll the current line to the top/bottom of the window.
Scroll to top (Ctrl+Alt+Up)
Scroll to bottom (Ctrl+Alt+Down)
Cursor to top (Ctrl+Up)
Cursor to bottom (Ctrl+Down)
The keystrokes I've used were chosen based on this scheme: Right-Arrow moves forward one char, Ctrl+Right moves forward one word, so: Up-Arrow moves up one line, Ctrl+Up moves to top of window. (Maybe "top of paragraph" would be more semantically correct, but I don't really use "paragraph" as an organizing concept in my code.)
I've also assigned, per my own logic, Alt+Up to scroll up one line, so Ctrl+Alt+Up scrolls to the top.