Alex B
Alex B

Reputation: 84962

Check if Vim split window is most bottom/most right

Is it possible in VimScript to detect if a split window touches the bottom and/or right margin of the real window?

Upvotes: 4

Views: 702

Answers (1)

mattn
mattn

Reputation: 7733

Try this.

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

Upvotes: 5

Related Questions