Is there any way to run multiple vim windows from one vim process, with them sharing the same internal clipboard?
To me, the window manager handling the window arrangement feels like The Right Thing, but vim handling the clipboard also feels right (because it interacts with many commands). So I'd like some hybrid of the two options of: 1) running multiple WM-managed vim instances; vs. 2) running one vim with vim-internal window management. I basically agree with the goal of running vim with dwm window management, but it seems wrong to have to reimplement dwm inside of vim, instead of using dwm itself to manage vim windows.
For 2) you can use tabs in Vim to provide different workspaces, with each workspace having a certain layout of windows.
I've just found out that dwm.vim doesn't work well with tabs just yet though - it copies all buffer windows to the current tab on Ctrl-f (make active window the master focus).
As an aside, you should also note that you can interact with the X clipboard from within vim or gvim. It's represented by the * register, so you can do things like "[asterisk]p to paste from other programs or "*Y to yank to them. Replace [asterisk] with the actual symbol. HN thought I was trying to italicize.
If your vim is on a box with an X server, look into client/server mode. You can then specify if you want to open a file in its own process or in the server process you spawned earlier.
Also, you can set the default yank register to be your X clipboard. Look into set clipboard = unnamed+ (make sure your vim is complied with X support for both of these)
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!
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.
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
+1 for tmux, I've been using it for a few months and loving every minute of it. One question about tmux/dwm.vim, though: Is there a way we could have the "focus"/automatic layout feature in tmux?
I'd love to press a key combo and have tmux bring my current pane to the large left panel, switching it with whatever I had there before.
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.
It forces a tiled layout that helps productivity by:
- keeping all buffers visible
- making jumping from one to another very easy
- driving focus on the main buffer
The advantages are well-known and demonstrated by dwm from which this plugin is inspired
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)
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.
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.
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.
This can be a common problem especially when working with a module which occupies a split, but doesn't depend on the file you're working on, like NERDTree. I've solved this problem in a fairly lightweight and elegant manner with the Bclose module, however, by (c)mapping bd to Bclose
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.
> 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.
Steamlined UX. With Vim split windows, I have to care about positioning. I need to rescale the windows so that I can see the code effectively. I need to think about window management. This automates it for me, and I have one less thing to think about.
Flexibility can be nice, but it can also get annoying. I don't want to micromanage behavior if the environment can do the right thing for me.
I frequently work with one vertical split in the middle with a class file on one side and the related spec on the other. I can relate to wanting to have a standard layout. I just frequently, split up the windows even more as I work. I used to find splits difficult to manage, but then I got used to/addicted to them. Personally, I would have difficulty with a fixed layout, but I can understand how it could be appealing.
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 :)
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.
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.
Thanks :) That seems to have done the trick. Now I just need to get my color scheme working right in iTerm. Still pretty new to Mac OS. I'm really a Linux guy.
I always used terminal vim when on Linux, but after I got a macbook (from work - I'd never buy one), I'm pretty happy with MacVim. Give it a shot.
Pretty much everything works out of the box as with the terminal version, you just get a few usability improvements (OS-integrated clipboard, mouse selections create vim selections and vice versa, etc).
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.
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!
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.
Yep, this is almost exactly what I do normally with vim, but that I have another column for nerdtree and possibly 6-8 splits. I find that it's pretty easy to move around, and that I can bring out tabs with a work-area for each thing I'm working on.
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.
Not sure it provides "90% of this". Your mappings ARE really cool (in fact I've just added them to my .vimrc, thanks).
I think the nicest feature of dwm.vim, though, is the "focus" and automatic layout of windows. Big left pane + lots of small panes on the right seems like a nice way of doing things...
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.
86 comments
[ 2.6 ms ] story [ 130 ms ] threadTo me, the window manager handling the window arrangement feels like The Right Thing, but vim handling the clipboard also feels right (because it interacts with many commands). So I'd like some hybrid of the two options of: 1) running multiple WM-managed vim instances; vs. 2) running one vim with vim-internal window management. I basically agree with the goal of running vim with dwm window management, but it seems wrong to have to reimplement dwm inside of vim, instead of using dwm itself to manage vim windows.
I've just found out that dwm.vim doesn't work well with tabs just yet though - it copies all buffer windows to the current tab on Ctrl-f (make active window the master focus).
Also, you can set the default yank register to be your X clipboard. Look into set clipboard = unnamed+ (make sure your vim is complied with X support for both of these)
Yes, though you will need a Vim with support for it built. See `:h client-server` for details. (I never really got into using it regularly)
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.
I'd love to press a key combo and have tmux bring my current pane to the large left panel, switching it with whatever I had there before.
The advantages are well-known and demonstrated by dwm from which this plugin is inspired
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
Oh, and make it work with tmux's splits, too!
http://superuser.com/questions/465780/anyone-know-how-i-can-...
http://www.quora.com/tmux/How-can-I-use-the-same-keys-to-mov...
Unrelated, but I also enjoy being able to Ctrl+w,Shift+[hjkl] to move splits around relative to the other splits.
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.
Flexibility can be nice, but it can also get annoying. I don't want to micromanage behavior if the environment can do the right thing for me.
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 :)
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.
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
Switching to zsh and oh-my-zsh has helped a lot too
Pretty much everything works out of the box as with the terminal version, you just get a few usability improvements (OS-integrated clipboard, mouse selections create vim selections and vice versa, etc).
It does not, you have to use the MouseTerm SIMBL plugin.
Works For Me™
Using lilyterm[0], a libvte based terminal.
[0] http://lilyterm.luna.com.tw/
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.
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.
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.
I think the nicest feature of dwm.vim, though, is the "focus" and automatic layout of windows. Big left pane + lots of small panes on the right seems like a nice way of doing things...