检查Vim拆分窗口是否位于最底部/最右侧



在VimScript中是否可以检测拆分窗口是否接触到真实窗口的底部和/或右侧边缘?

试试这个。

碎片:

func! IsMostBottomRight(nr)
  let oldw = winnr()
  silent! exe "normal! <c-w>l"
  silent! exe "normal! <c-w>j"
  let neww = winnr()
  silent! exe oldw.'wincmd w'
  return oldw == neww
endfunction
" echo IsMostBottomRight(winnr())

固定:

func! IsMostBottomRight()
  let oldw = winnr()
  silent! exe "normal! <c-w>l"
  silent! exe "normal! <c-w>j"
  let neww = winnr()
  silent! exe oldw.'wincmd w'
  return oldw == neww
endfunction
" echo IsMostBottomRight()

最新更新