'Scrolling window without using Control key in Vim
Is it possible to scroll window screen without using control + U or control + D, (or control + F,B,E etc). I am aware that I can use 'j' or 'k', but that is a line by line scroll. I am looking to scroll through a larger chunk of text without using control key. I find it little inconvenient to move from home row. (May be I am thinking too much.)
I am aware that I can use /search or nG to move to a particular line. But sometimes, it is helpful to scroll through the code, without a specific line.
I am using GVim (windows). Thank you.
Solution 1:[1]
<C-U> / <C-D> scroll by 'scroll' number of lines. You can emulate that via
:execute 'normal!' &scroll . 'j'
This is too long to type, so you need a mapping, but that probably again would involve a modifier key. For ad-hoc scrolling, just estimate the amount of lines and type 30j.
That said, modifier keys are important in Vim (even if less than in Emacs). Maybe you should consider remapping Ctrl, for example to Caps Lock?
Solution 2:[2]
As I wise friend once showed me, you can use L to move cursor to the
bottom of the current window frame. Similarly, you can use H to go to
the top, or M to go to the middle, and also you can then scroll to
center the frame on the cursor location with zz.
With that, you can scroll down with L zt, and up with H zb. Half
scroll with L zz, H zz.
Better yet, if you're using spacemacs, you can use SPC N f or SPC N b to scroll forward and back. Either of which will put you in transient
state, meaning after you enter SPC N f subsequent commands are without
the prefix: f, b, u, d, until you exit the state.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ingo Karkat |
| Solution 2 |
