
Dwm.vim : Tiled Window Management for Vim  - sciurus
http://www.vim.org/scripts/script.php?script_id=4186
======
kristopolous
The most valuable two settings I know for this are:

set ttymouse=xterm2

set mouse=n

Now you can use the mouse to resize buffers and click on tabs. You can even
click to focus on a buffer and don't need to meta-press your way around when
you just want to browse things. Go on, click on topics inside of the help,
assign the right click to supertab[1], navigate NerdTree[2] like the explorer
clone it is. Collapse and expand code folds[3] like a 21st century digital
boy.[4]

Furthermore, your scrollwheel all of a sudden now scrolls through your
document in putty, xterm, screen, rxvt, tmux, iterm; all of them. Yes, total
heresy, I know.

The only thing more important than this is doing a visual selection[5] and
then doing a :!(any program) like say: fmt, sort, mail, python, rdoc, indent,
bc ...

I know what you are thinking; "But kristopolous, this is so easy; it is not
possible". Relax my friend, this is unix, you know this.

PS: Here's my custom vim builder/environment maker:
<https://github.com/kristopolous/vimbuild>

[1] <http://www.vim.org/scripts/script.php?script_id=1658>

[2] <http://www.vim.org/scripts/script.php?script_id=1643>

[3] <http://vimdoc.sourceforge.net/htmldoc/fold.html>

[4] <http://www.youtube.com/watch?v=ZN6kCgMUjFw>

[5] <http://vimdoc.sourceforge.net/htmldoc/visual.html>

~~~
jlgreco
Do you mean ` _set mouse=a_ `? ` _n_ ` just makes it work while in normal mode
iirc, while ` _a_ ` should work in any mode.

------
luriel
As one of the original instigators of dwm and wmii before that (mostly by
shouting at garbeam) I want to point out that this kind of tiled window
management was first introduced in larswm (that is sadly discontinued), which
in turn was heavily inspired by Rob Pike's Acme editing environment (
<http://acme.cat-v.org> ).

So in a way we have gone full circle, from text editor, to window managers,
back to text editor.

That said, I still prefer Acme to vim, but would be really cool if somebody
added mouse chording to vim :)

~~~
pyre

       I still prefer Acme to vim
    

If you could expand on that (compare/contrast), I would definitely be
interesting in reading it (blogpost, Show HN, etc).

~~~
luriel
The philosophies of acme and vim are so completely different that is very
difficult to even compare.

One of my favorite things about Acme is that it requires basically no
configuration, you can write small scripts to perform certain tasks, so in a
way it is 'scriptable', but this are usually little more than shell pipelines
to transform text.

I remember spending hours in vim simply looking around the huge mountains of
documentation to find the right option to add to to my every growing vimrc,
and when you wanted to do something slightly complex you had to use the rather
bizarre vimscript.

Yes, vim has bindings for python and ruby and a bunch of other languages, but
this brings us to another issue with vim: every installation seems to be
almost unique, it has no consistent defaults, or even available features, so
even carrying your personal vimrc arond (which is a pain in the ass) is not
enough as it might depend on some feature not enabled in whatever vim binary
you will find in a given system.

Window management and mouse chording in acme are simply a dream, while in vim
i can rarely remember all the commands needed to manage windows, and the mouse
is basically useless.

I could go on, but if you have tried both, you will realize that the
differences are quite fundamental and even philosophical, so I don't expect
every vim-head to understand and appreciate acme right away, because it will
not fit with what they expect from a text editor.

All that said, I still use ed for quick edits, in part because it provides a
consistent and almost universal interface, the trend some Linux distributions
have of removing one of the most venerable and ancient Unix commands is very,
very disturbing.

------
mukaiji
HN needs more posts like this. just saying...

~~~
pooriaazimi
Indeed. My dream HN has 30 of these posts on its front page.

------
mrinterweb
Not quite figuring out how this is functionally different than vim's split
buffers. Just seems less flexible than splits in that it did not mention that
tiled windows could be repositioned or resized.

~~~
msbarnett
By default Vim's split buffers have some fairly annoying behaviours -- for
example, if you accidentally close the file browser you have taking up the
entire left hand of the window, all of the other buffers gobble up that space
instead of retaining your painstakingly assembled layout.

~~~
mrinterweb
I guess to each their own, but I like the default behavior of when a split
buffers is closed that the other buffers resize to fill the void. I'd prefer
to see the space available used rather than trying to find something to fill
the empty buffer with.

Unrelated, but I also enjoy being able to Ctrl+w,Shift+[hjkl] to move splits
around relative to the other splits.

~~~
msbarnett
> I guess to each their own, but I like the default behavior of when a split
> buffers is closed that the other buffers resize to fill the void. I'd prefer
> to see the space available used rather than trying to find something to fill
> the empty buffer with.

Yeah, but the point is I closed it _accidentally_. So now I reopen NERDTree or
whatever and have to spend a bunch of time micromanaging my splits back into
the arrangement I just had them in.

Wasted space sucks, but so does having things wreck my layout in an over-eager
attempt to avoid it.

------
xyzzyb
I don't understand. What does this do that vim buffer windows don't already
manage?

~~~
arnarbi
Presumably only the arrangement and sizing of windows. I.e. you don't have to
:split or :vsplit manually, just create or delete windows and they'll be
arranged according to the layout algorithm.

~~~
spolu
Yep, that's even better said

------
evan2m
I recommend Golden-ratio for this kind of thing:

<http://www.vim.org/scripts/script.php?script_id=3690>

It does not take away the ability to do :split or :vsplit or force a
particular layout. It does dynamically resize your windows to maximize
visibility

~~~
spolu
Yep, that's a different religion. But it's just as good.

------
spolu
Here's a screenshot as well <http://i.imgur.com/TKL4i.png> available on the
github of the script <https://github.com/spolu/dwm.vim>

------
devgutt
I use TMUX with VIM for that.

~~~
arnarbi
I use XMONAD with VIM for that. :)

~~~
milkmiruku
I got into Awesome Window Manager a couple of months ago and have been getting
to know how to manage remote Vim split windows with the help of NERDTree. A
remote in-Vim managed tiling aproach would be cool though. Googling around,
there's also <https://github.com/fabi1cazenave/suckless.vim> which emulates
wmii and has "[s]tacked, [d]ivided, [f]ullscreen" modes. I need to learn tabs
also. Things can get busy on 1024*768!

~~~
milkmiruku
awesome wm, urxvt, ssh, tmux, vim, dwm.vim <http://i.imgur.com/fC556.png>

nerdtree <cr> opens things in the active window, nerdtree i opens a split in
the master window, and a dwm.vim focus tidies things up. no fullscreen mode is
unhandy though (i've not learnt how to unmaximise from Ctrl-w _ and Ctrl-w |
yet).

edit; silly me, doing Ctrl-f now unmaximises the window.

~~~
spolu
THAT's AWESOME!!! Please file an issue with how you would see the user
interface for a fullscreen mode. I'll be happy to add it asap! ->
<https://github.com/spolu/dwm.vim>

~~~
milkmiruku
done. as noted there, Ctrl-w | Ctrl-w _ to fullscreen does leave the other
windows crushed at the edge, but i guess there might be a better method?

------
lucaspiller
I have this in my vimrc which provides 90% of this:

    
    
        noremap <C-h> <C-w>h
        noremap <C-j> <C-w>j
        noremap <C-k> <C-w>k
        noremap <C-l> <C-w>l
    

You can then jump between splits with Ctrl and the navigation keys.

~~~
linhat
Same here.

I do not really understand the need to have a 'window manager' inside vim. I'm
a long xmonad user and I think tiling window managers are great (wish there
would be a worthy native os x implementation), but adding yet another plugin
to my vim setup doesn't really seem feasible, especially when one can map its
core functions with a couple of lines. Vim provides uncountable ways to manage
splits, including resizing, switching etc, and then there is still vim's great
tabs feature to be discovered to reduce the on-screen mess splits can
produce...

That said, hat-tips to the author for managing to create a plugin for vim
using its rather obscure vi/ex language.

------
lorenzfx
it would be awesome, if I could somehow use the same keys to switch between
vim splits and my (tiling) window manager's windows. First move focus in vim,
if I'm already in the utmost split then move the focus to the next window.

Oh, and make it work with tmux's splits, too!

~~~
eterps
I am also looking for this functionality:

[http://superuser.com/questions/465780/anyone-know-how-i-
can-...](http://superuser.com/questions/465780/anyone-know-how-i-can-use-the-
same-keys-to-move-between-vim-windows-as-well-as-t)

[http://www.quora.com/tmux/How-can-I-use-the-same-keys-to-
mov...](http://www.quora.com/tmux/How-can-I-use-the-same-keys-to-move-between-
Vim-windows-as-well-as-Tmux-or-tiling-WM-panes)

------
spolu
Now this is what happens when you do: dwm.vim < vim < tmux < vps < ssh < tmux
< gnome terminal <http://i.imgur.com/WR9JC.png> (courtesy of romainl on
reddit/r/wim)

------
grannyg00se
One vertical split and two horizontal splits. Vim already does that. What does
this add?

~~~
exDM69
It lays out the windows automatically in Vim like dwm and similar window
managers do on X11. Manually opening and moving windows is a bit tedious, this
might help.

------
pooriaazimi
Absolutely wonderful. I had another plugin like this (that probably came with
`janus`) and did the tiling, but was really complicated and I never get to use
it anymore.

Something odd though: Isn't ^f supposed to do a 'page down' by default? The
'focus' part of his plugin didn't work for me and I had to change the mapping
to ^m instead.

~~~
spolu
This has been changed to ^h (<https://github.com/spolu/dwm.vim/issues/2>) You
still need to download from github at this stage. Will push a new version
today. Thanks!

------
csl
I use iTerm2 on OS X with window splitting, with focus that follows mouse.
Here is an example using several vim processes:

<http://i.imgur.com/Xsh8f.png>

Of course, you lose the ability to use vim copy buffers between the processes,
but it works well and I like the look of it.

~~~
klez
I badly want your status bar layout (arrows and colours). How did you do that?

~~~
supo
<https://github.com/Lokaltog/vim-powerline> there ;-)

~~~
js4all
This thread is full of great tips. Thanks for the power line pointer.

------
cturner
I think it's a mistake to overload ctrl+b. That's taken by standard vi
functionality. If I'd written this, I'd have been tempted to use ` as a
leader. So `n would open a new window. `b would open that buffers view
currently bound to ctrl+b.

------
firefoxman1
This is a really nice plugin. I actually already had Ctrl-N mapped to a
horizontal split, but this adds more functionality.

------
abhishekam
The ^F for focus doesn't seem to work - but the rest are really nice and
helpful. Thanks very much.

~~~
spolu
Possible that there is a mapping conflict with some of your scripts. (see
<https://github.com/spolu/dwm.vim/issues/2>)

------
rjzzleep
fast tiling splits in vim? hell yeah i say. one thing that would be nice,
would be to preserve window width ratio on ctrl-f

~~~
spolu
Yep, that's a good point. I'll file an issue on that
(<https://github.com/spolu/dwm.vim/issues/5>)

------
pinchyfingers
Emacs has awesome window management built in, just sayin'.

