I would like to use ctrl-k and ctrl-j to not only move the cursor up or down (by lines), but also to scroll the portion of the document that is visible. Effectively, leave the cursor where it is and move the document past it.
I can accomplish this for the most part using:
:nnoremap <c-j> j<c-e> :nnoremap <c-k> k<c-y>
However, this has two issues:
- Minor issue: when the cursor is at the bottom visible line (
L) or the top visible line (
H), then an extra line is shown by ctrl-j and ctrl-k respectively (undesirable behavior).
- Major issue: this shortcut doesn't work with counts.
How can I improve on my solution to avoid these issues?