Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panes spawed with :split can break layout #41

Open
captbaritone opened this issue Dec 5, 2012 · 7 comments
Open

Panes spawed with :split can break layout #41

captbaritone opened this issue Dec 5, 2012 · 7 comments

Comments

@captbaritone
Copy link

Hopefully, I'm just missing something here, but if I follow the following steps, I end up with three equal vertical splits rather than one focused split and the other two stacked on the right:

  1. Open vim: vim
  2. Create a new split: :split
  3. Focus the current split: <C-Space>
  4. Create a new split: :split
  5. Focus the current split: <C-Space>

If I then move to one of the three equal panes, and focus that pane, the correct layout is returned. It looks like it has something to do with splitting the focused pane and then focusing the new split. Similarly, if I split a non-focused pane and then focus, the correct layout is maintained.

I have tested this on MacVim, and Vim (7.3) on OSX and Ubuntu.

Edit: I've looked into this further, and it looks like this plugin makes no attempt to organize splits that are outside of it's expected layout. Would that be outside of the scope of this plugin, or a welcome improvement?

@captbaritone
Copy link
Author

I have added some code to the bottom of DWM_Stack() which will cycle through all the windows, putting each one at the top so that we can be sure all the windows are actually stacked even if we started win a non-standard window layout. The upshot is, that focusing a window will put us into the DWN layout no matter what the layout was before.

Here is the code I have added:

" Get the number of the current window so we can come back here
let l:curwin=winnr()
" Cycle through all the windows, putting each one at the bottom
let l:i=1
while l:i <= winnr('$')
  1wincmd w
  wincmd J
  let l:i += 1
endwhile
" Return to the window we started in
exec l:curwin . "wincmd w"

It feels like a bit of a hack, but I don't see any better way to do it. If this is functionality you are interested in, I can generate a pull request.

Edit: Just saw that @jdonaldson has already done this on his one commit to his fork and his approach is slightly cleaner. I have updated by code accordingly.

@spolu
Copy link
Owner

spolu commented Jan 2, 2013

The commit from @jdonaldson unfortunately breaks more situations than it fixes. So there's no fix to that for now...

@ghost
Copy link

ghost commented Jan 20, 2013

it seems it doesn't work now,the window didn't split,and if I split it manually it's not what it should be,and C-N is conflicted with something.

@spolu
Copy link
Owner

spolu commented Jan 20, 2013

@ellrywych What is not working?

@ghost
Copy link

ghost commented Jan 20, 2013

@spolu maybe I shouldn't post that reply in this thread.
It says "Windows are always organised as follows:

"
windows are not shown like that neither I start vim nor I split windows by my own.

Should I just put dwm.vim in plugin path and it will work?
Simply I don't know how to make it look like that screenshot .

@spolu
Copy link
Owner

spolu commented Jan 20, 2013

@ellrywych This does not belong to that stream at all indeed.

You should split your windows with C-N if it does not work maybe it's because you already binded C-N...
Normal :split are not affected by dwm.vim

@ghost
Copy link

ghost commented Apr 27, 2016

Thank you @spolu @captbaritone

@ghost ghost mentioned this issue Apr 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants