Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to overload my tmux binding which cycles through panes to also cycle through Vim windows if the current pane happens to be running Vim.

I can detect the presence of Vim by checking the pane title, but this is not robust because vim could have been resumed via fg and this will fail. that's fine, I can just avoid suspending vim (I am after all in tmux).

Okay, but now Tmux must know whether current pane running Vim has a single window open (in which case switch panes) or if current pane running Vim has more than one window open.

I'm positive that this can be done. The solution can be anything from straightforward to difficult and fragile.

How can I query Vim about

  • how many windows are open, and
  • which window index is currently focused?
share|improve this question

migrated from stackoverflow.com May 15 '13 at 21:09

This question came from our site for professional and enthusiast programmers.

    
When will this tmux+vim madness stop? –  romainl May 15 '13 at 18:24
    
You may want to look at the following gists before you roll your own: gist.github.com/mislav/5189704 and gist.github.com/tarruda/5158535 –  Peter Rincker May 15 '13 at 18:25
    
Thanks @PeterRincker looks like someone has considered this already –  Steven Lu May 15 '13 at 18:37
    
Awesome, so the way they got this working was to have vim call tmux back when there are no more vim windows in the specified direction. This is crazy because the command to switch windows originally comes from tmux to begin with! I didnt know vim could do that. It obsoletes my "does vim have more than 1 window open" question. –  Steven Lu May 15 '13 at 18:45
2  
Your question is a pretty good illustration of why this madness should stop: you stack up and nest programs with overlapping but slightly different features and conflicting shortcuts and you end up building convoluted hacks to reach a frivolous and illusory feeling of integration. tmux is great and dependable until you want to make it the center of your workflow. Frankly, using Vim in a terminal is so simple… why do people need to over complicate things? If you need an IDE, get an IDE. –  romainl May 15 '13 at 19:01

1 Answer 1

up vote 0 down vote accepted

The perfect solution is here.

https://gist.github.com/mislav/5189704

share|improve this answer

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.