If I do :let id = popup_create(['hello', 'hello', ... a lot of these, 'hello'], {}), I can reproduce the case of a popup that contains more items that its height, thus having a scrollbar.

How do I scroll that bar via keyboard? Is it possible?

:help popup-scrollbar mentions the mouse several times, so it suggests to me that probably it's simply not possible to scroll via keyboard. Is that the case?

1 Answer 1


After some digging I found this great blog post by @fortime.

I adapted their code for my needs (fixed a bug and keep the scrollbar visible):

function! ScrollPopup(nlines)
    let winids = popup_list()
    if len(winids) == 0

    " Ignore hidden popups
    let prop = popup_getpos(winids[0])
    if prop.visible != 1

    let firstline = prop.firstline + a:nlines
    let buf_lastline = str2nr(trim(win_execute(winids[0], "echo line('$')")))
    if firstline < 1
        let firstline = 1
    elseif prop.lastline + a:nlines > buf_lastline
        let firstline = buf_lastline + prop.firstline - prop.lastline

    call popup_setoptions(winids[0], {'firstline': firstline})

You can add your own keybindings to call ScrollPopup, for example:

nnoremap <C-j> :call ScrollPopup(3)<CR>
nnoremap <C-k> :call ScrollPopup(-3)<CR>
  • 1
    Nice answer & Welcome vi.SE deox
    – gildux
    Feb 8, 2023 at 20:20
  • Awesome, can't thank you enough
    – kjones
    Jan 24 at 22:10

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.