this post was submitted on 16 Jul 2023
16 points (100.0% liked)

Neovim

2161 readers
4 users here now

founded 1 year ago
MODERATORS
 

I like mixing the keyboard and mouse. Yes I know

set mouse=a

exists, but it provides only some basic actions. I was wondering if you could map the mouse to allow moving split window panes around - something which is painful to do by keyboard. Do you know of something like this?

#vim #neovim

@vim @neovim

top 9 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 1 year ago (2 children)

@ashwinvis @vim @neovim This _should_ work out of the box…? Does mouse dragging allow you to create a visual selection? If not, your terminal’s mouse reporting is probably not recognized correctly by (Neo)Vim, or it doesn’t report dragging at all.

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago) (1 children)

@scy @ashwinvis @vim @neovim in my experience this works for *resizing* but not moving windows/panels around.

My solution to that is keyboard driven, but it's a plugin i wrote which allows swapping the currently focused window with a different one, by typing its letter.

I only tested it on vim, not neovim, but if it's possible to make it neovim compatible, i do welcome patches.

https://asciinema.org/a/0laV3PGpmCXkkazet0hIRf51W

https://github.com/tshirtman/vim-winny

[–] [email protected] 4 points 1 year ago (2 children)

@tshirtman
Ooh... like a tiling window manager. I will check it out. I like the labelled popups in front of panes.

I see something similar written in Lua.

https://github.com/sindrets/winshift.nvim

@scy @vim @neovim

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

@ashwinvis @scy @vim @neovim oh the one you found seem more powerful than mine, behaving a lot more like i3wm, nice, sadly only neovim compatible, but it's nice to know it exists, panes management is really a pain point in vim when you open more than a couple of them.

[–] [email protected] 3 points 1 year ago (1 children)

@scy
I can select text, resize window panes - that works.

What I am looking for is a way to:

move left pane to right,
move bottom right pane to top left corner etc.

@vim @neovim

[–] [email protected] 2 points 1 year ago (1 children)

@ashwinvis @vim @neovim Oh! Now I understand. Sorry.

Good question, I don’t know of any way, but I’d be interested in finding out, too, now ;)

[–] [email protected] 2 points 1 year ago

@scy
Indeed. Something is available in nearly every IDEs, and painfully neglected in Vim, Neovim :harold:
@vim @neovim

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

What I am looking for is a way to: move left pane to right, move bottom right pane to top left corner etc.

The method I use to move windows around is similar to what I do with text -- "d" the window, then "p" it elsewhere. Except the mappings are <c-w>d and <c-w>p: https://github.com/andrewradev/yankwin.vim

I doubt this plugin would be convenient to you out of the box, since for instance it doesn't paste vertical splits, and if you have lots of windows, maybe you use a large monitor with them. I'd say you could use it as an idea at least. The core of it is as simple as this: https://github.com/AndrewRadev/vim-lectures/blob/4bb97b3a2cb27fb8542d494079ee2ffde4a49d93/snippets/03-winmove.vim

If you wanted to use the mouse, you could map <LeftMouse>, <MiddleMouse>, and <RightMouse> for it. Possibly with ctrl or some other modifier. There's even <LeftDrag>, but I haven't experimented with it, so I can't say if it would be easy to implement drag & drop for windows. :help mouse-overview.

load more comments
view more: next ›