开发者

Can I scroll the file up or down in an inactive window in Vim?

Say, I split my Vim screen into two windows. And I need to s开发者_运维技巧croll inactive window. Example to scroll up/down preview window without placing a cursor into preview window.


You could add a couple of custom mappings:

:nmap ,d <C-W>W<C-D><C-W>W
:nmap ,u <C-W>W<C-U><C-W>W

and then use ,d and ,u to scroll down and up in the other window.


"this function maps Alt-down and Alt-Up to move other window
" put in your ~/.vimrc
fun! ScrollOtherWindow(dir)
    if a:dir == "down"
        let move = "\<C-E>"
    elseif a:dir == "up"
        let move = "\<C-Y>"
    endif
    exec "normal \<C-W>p" . move . "\<C-W>p"
endfun
nmap <silent> <M-Down> :call ScrollOtherWindow("down")<CR>
nmap <silent> <M-Up> :call ScrollOtherWindow("up")<CR>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜