检查Vim分割窗口是否最底部/最右边

时间:2011-06-22 06:29:04

标签: vim

是否可以在VimScript中检测分割窗口是否触及真实窗口的底部和/或右边距?

1 个答案:

答案 0 :(得分:5)

试试这个。

BITS BROKEN:

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())

FIXED:

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()