There are 2 and only windows in vim. I want when I press F2, cursor remain in the same window, the other window behave like PgDnpressed.

How to achieve that behavior?


motivation: used in a preview mode, one window containing a dirvish buffer.


I think the following mapping should to the trick

nnoremap <F2> <C-w>p<C-f><C-w>p

It remaps F2 to change to the previously accessed window (:h CTRL-W_p), scroll down (:h CTRL-F) and come back to the previous window.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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