I already know如何使用diffopt
变量启动具有水平/垂直拆分的diff模式,但不是在我已经打开两个文件进行比较时如何在两者之间切换。
我尝试了在this older post中找到的公认答案,但无济于事。Ctrl+W命令对我不起作用。也许是因为我在Windows友好模式下运行gVim?
发布于 2018-05-17 14:52:46
我来晚了,但也许这是一个有趣的解决方案。@PeterRincker的解决方案只有在你只打开了几个窗口而没有内部窗口的情况下才有效。
我在我的运行时配置中发现了这个(有用的)函数,我想和你分享。它的目的是映射为键绑定,让用户将当前的拆分切换到指定的拆分。标记它不会在垂直和水平之间切换,但用户会告诉他喜欢哪一个(如果这个场景没有意义,也可能是当前活动的)。Vim窗口树总是有两个窗口作为“合作伙伴”。在调整窗口大小时,也可以观察到这种影响。我想说的是:如果应用于当前活动窗口及其“伙伴”窗口,则触发函数。
" Switch to a vertical or horizontal split between two windows.
" Switching to currently used split results into the equal split.
" This is between the current window and the one window which is focused, when close the active window.
" This function does not adjust the windows height after the switch, cause this can't work correctly.
"
" Arguments:
" horizontal - Boolean to differ between both layouts.
"
function! s:switch_window_split(horizontal) abort
let l:bufnr = bufnr('%') " Get current buffer number to restore it in the new window.
if a:horizontal | let l:vert = '' | else | let l:vert = 'vert ' | endif
" Close current window and open new split with the cached buffer number.
wincmd c
execute l:vert . 'sbuffer ' . l:bufnr
endfunction
" Switch split layout.
nnoremap <leader>wS :<C-u>call <SID>switch_window_split(v:true)<CR>
nnoremap <leader>wV :<C-u>call <SID>switch_window_split(v:false)<CR>
不幸的是,它目前仍然改变窗口的大小,而不是保持形状不变。我正在努力,但实现起来并不容易,因为我必须知道“合作伙伴”窗口的形状。
发布于 2016-10-17 21:26:53
也可以按住ctrl-w
+ <arrow key>
来选择窗口。
https://stackoverflow.com/questions/5682759
复制