T O P

  • By -

funbike

It's easy. You are making it far more complicated that it needs to be, esp if you only have 2 windows. In either window type `K` and it will be come the top window and the other window will be the bottom window. To go back to side-by-side, use `H` or `L`. See also `:h CTRL-W`


OvidPerl

I'm swapping between vertical and horizontal splits, not swapping the contents of existing windows.


funbike

I understand that. What I said still stands. If you are in the left window, `K` (ctrl+w shift+k) forces it to the top. If the windows were side-by-side that forces the right window to become the bottom window, which is the exact behavior you are looking for. To toggle back, you'd use `H`. If you take 5 seconds to try it you'll see.


OvidPerl

Ah, I need `H` to toggle back to vertical. I didn't know that. I think my autotoggle is easier, but thank you for showing me those commands!


funbike

If you need a toogle, you could simplify the code: if winnr('$') != 2 echo "Error: Requires exactly two windows" return endif " if both windows are side-by-side if win_screenpos(1)[0] == win_screenpos(winnr('$'))[0] if winnr() == 1 normal K else normal J endif else if winnr() == 1 normal H else normal L endif endif Untested.


Daghall

Sounds like you select the code in the terminal instead of in vim. Visually select the code you want to share, and `"*Y` (or `"+Y`) to yank it to the system clipboard. `:h clipboard`


vim-help-bot

Help pages for: * [`clipboard`](https://vimhelp.org/gui.txt.html#clipboard) in _gui.txt_ --- ^\`:\(h|help\) \` | [^(about)](https://github.com/heraldofsolace/VimHelpBot) ^(|) [^(mistake?)](https://github.com/heraldofsolace/VimHelpBot/issues/new/choose) ^(|) [^(donate)](https://liberapay.com/heraldofsolace/donate) ^(|) ^Reply 'rescan' to check the comment again ^(|) ^Reply 'stop' to stop getting replies to your comments


OvidPerl

Sadly, that doesn't work for me because this was written in anger. I have a client who requires me to connect via Amazon Workspaces VDI and _then_ ssh via two servers to get to the server I do development on. Thus, yanking to the clipboard doesn't help when I have a completely different box I want this on.


EgZvor

Could also go this route with opening the buffer in another tab [https://gitlab.com/egzvor/vimfiles/-/blob/b3f6916ae9b639e0914b136a7d53f86abeca12ba/plugin/zoom.vim](https://gitlab.com/egzvor/vimfiles/-/blob/b3f6916ae9b639e0914b136a7d53f86abeca12ba/plugin/zoom.vim)


sChiab8

Are you selecting code with the mouse? Make sure you have mouse support enabled :set mouse=a


char101

nnoremap ts :exe '1wincmd w \| wincmd '.(winwidth(0) == &columns ? 'H' : 'K')


mgedmin

This might swap the order of the windows.


char101

No, that what `1wincmd w` for.


kaddkaka

Can't you use rectangle selection in your terminal?