I often find scrolling a full page too disorienting, half a page too much, but a quarter page is just right. I currently do it just by holding down the arrow keys.

How do I scroll 25% of the page down and up easily?


5 Answers 5


Maybe ctrld and ctrlu could be what you are looking for. By default they move half of the screen.

From :h CTRL-D:

Scroll window Downwards in the buffer. The number of lines comes from the 'scroll' option (default: half a screen).

If [count] given, first set 'scroll' option to [count].

Which means that the first time you want to scroll in a window you can do XXctrld where XX is the 25% of the number of lines in your window. As it sets scroll to the XX value you can then use ctrld and ctrlu to move 25% of the screen.

Also, I think that :h scrolling might be interesting for you.


And here is another solution with a function and some mappings to add to your .vimrc:

function! ScrollQuarter(move)
    let height=winheight(0)

    if a:move == 'up'
        let key="\<C-Y>"
        let key="\<C-E>"

    execute 'normal! ' . height/4 . key

nnoremap <silent> <up> :call ScrollQuarter('up')<CR>
nnoremap <silent> <down> :call ScrollQuarter('down')<CR>

The function will get the height of the current window, and accordingly to its parameter will scroll the screen up or down of a quarter of the height.

The mappings will call the function, the first one to go up and the second one to go down.

Of course, you can change <up> and <down> to some other keys if you want to keep the default behavior of your arrow keys.

  • 2
    Seems like it might make more sense to use ctrl-E and ctrl-Y in the mappings, because a). you then have separate shortcuts for both 1/2 page and 1/4 page scrolling. b). the behaviour of ctrl-U/ctrl-D is consistent and not dependent on whether you have previously used the mapping.
    – Rich
    Commented Oct 25, 2016 at 12:36
  • I don't understand your important note. What do you mean enter manually? Currently using this deletes a line instead of moving the page.
    – Louis Hong
    Commented Oct 25, 2016 at 18:00
  • @LouisHong See the line let key="^U" the part between the double quote is meant to represent the key code of ctrl+u. So if you copied the function in vim put your cursor on the first double quote hit ci" to modify the content of the quotes and then hit ctrl+v followed by ctrl+u to the same on the line let key="^D".
    – statox
    Commented Oct 25, 2016 at 18:11
  • @Rich: Yup that's a good point. I used the arrow keys because that's what OP said he used but your point is relevant.
    – statox
    Commented Oct 26, 2016 at 9:06
  • @statox You misunderstood me! (I wasn't clear). I meant use let key="^Y" instead of let key="^U". It will create the same behaviour but without affecting the 'scroll' setting.
    – Rich
    Commented Oct 26, 2016 at 9:31

You can use ctrle and ctrly to move the page by one line up and down.

Then if you want for +/- 25% to be moved you can use 20ctrle and that will move you 20 lines down.

Here is also a good explained question that is similiar to yours: https://stackoverflow.com/questions/3458689/how-to-move-screen-without-moving-cursor-in-vim


I variated statox approach so it scrolls more consistent over the linewraps. If you want a quarter step, change 0.618 back to 0.25 or whatever.

function! ScrollGolden(move)
    let height=winheight(0)
    if a:move == 'up'
        let prep='L'
        " let key="^Y"
        let key='gk'
        let post='zb'
    elseif a:move == 'down'
        let prep='H'
        " let key="^E"
        let key='gj'
        let post='zt'
    execute 'normal! ' . prep . float2nr(round(height*0.618)) . key . post
nnoremap <silent> <BS>    :call ScrollGolden('up')<CR>
nnoremap <silent> <Space> :call ScrollGolden('down')<CR>

If your wanting a good general answer and not an exact 25% you could factor the normal line count on a page by divide by 25 and set some system mappings. For instance if you normally have about 100 line on a screen at a time then 25% of that is 25 lines so you could set a key mapping on something like your capital J and K for quickly moving up and down 25 lines

noremap J 25j
noremap K 25k

If your wanting to just jump to the quarter mark of the entire file then in normal mode just type:

  • 1
    I think there's two drawback with your solution: noremap J 25j hardcodes the value 25 thus when for example you horizontally split a 100 lines window your mapping will actually navigate 50% of the new windows. About your second option :25% I didn't knew it existed but from my tests it seems that it puts the cursor on a position based on the first line: if I have a 100 lines buffer and I want to move 25% forward typing :25% will bring me on line 25 no matter where my cursor was. Also could you please put the help topic describing this feature I can't find it in the doc?
    – statox
    Commented Oct 27, 2016 at 8:09
  • 1
    I found the help topic at :h N% :-)
    – statox
    Commented Oct 27, 2016 at 8:31

Here are simple one-line mappings that don't require a separate function. Putting these in your .vimrc will cause CTRL-j and CTRL-k to respectively move down or up 1/4 of the screen in insert, visual, and normal modes.

" insert mode
inoremap <expr> <C-j> '<ESC>'.winheight(0)/4.'<C-D>a'
inoremap <expr> <C-k> '<ESC>'.winheight(0)/4.'<C-U>a'

" visual mode
vnoremap <expr> <C-j> winheight(0)/4.'<C-D>'
vnoremap <expr> <C-k> winheight(0)/4.'<C-U>'

" normal mode
nnoremap <expr> <C-j> winheight(0)/4.'<C-D>'
nnoremap <expr> <C-k> winheight(0)/4.'<C-U>'

Adapted from this Reddit answer.

Bonus: Combine with the vim-smoothie plugin for animated smooth scrolling. If do this, replace inoremap with imap, vnoremap with vmap, and nnoremap with nmap to allow nested overrides of the keybindings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.