Vim: Move window left/right?

前端 未结 5 1230
野趣味
野趣味 2020-12-04 04:38

In Vim, is it possible to “move” a window to the left or right? Eg, similar to r or x, but left/right instead of up/down?

5条回答
  •  青春惊慌失措
    2020-12-04 04:59

    It really seems like vim can't do this with the standards key maps. The documentation says that the ^W K, J, H and L commands work by creating the split and opening the buffer in the now position, so I wrote a function to the same: Hide the buffer, move to the left, split, and then open the original buffer:

    " Rotate a window horizontally to the left
    function! RotateLeft()
        let l:curbuf = bufnr('%')
        hide
        wincmd h
        split
        exe 'buf' l:curbuf
    endfunc
    
    " Rotate a window horizontally to the right
    function! RotateRight()
        let l:curbuf = bufnr('%')
        hide
        wincmd l
        split
        exe 'buf' l:curbuf
    endfunc
    

提交回复
热议问题