Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to detect whether or not I am in the right most (or left, top, bottommost) split. In other words, when ctrl-w h would do nothing. Is there a way to do that?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

There's only winnr(), which is a sequential numbering; i.e. you can only check for topleft- and bottomright-most window, but not the exact window relations. If you need this information in a mapping / script, you'd have to do exactly as you've described:

function! IsLeftMostWindow()
    let curNr = winnr()
    wincmd h
    if winnr() == curNr
        return 1
    endif
    wincmd p " Move back.
    return 0
endfunction
share|improve this answer

If you are using split screens in vim, you will see in the bottom of all of the split screens a bar with the filename (and information about the position of the cursor). In the active window, the text in this bar bold-face. So by checking the bold-face text, you can immediately see which of the splits you activated.

share|improve this answer
    
I hope this is enough information, or is there a reason to have automatized detection? –  Bernhard Feb 22 '13 at 7:24
    
I was referring to from vimscript, I know how to tell which pane I'm in with my eyes :) –  Aaron Jensen Feb 23 '13 at 4:40
    
@AaronJensen I couldn't tell from your question, but you got a perfect answer anyhow :) –  Bernhard Feb 23 '13 at 9:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.