Expand vim split - vim

I've have splits open in vim which look like:
----------------
| A | B | C |
----------------
| D | E |
----------------
I'd like to expand the C split such that my splits look like:
----------------
| A | B | |
----------| C |
| D | E | |
----------------
Is there an easy way to do this?

Press <C-W>L in window C. See :h CTRL-W_L.

Related

Moving a split Vim window to the other half of the screen

Let's say we have 3 buffers (A, B, C) open in Vim arranged as follows
-----------------------------------------
| | |
| | |
| | |
| A | |
| | |
| | |
|------------------| B |
| | |
| | |
| C | |
| | |
| | |
-----------------------------------------
and we want to rearrange it as
-----------------------------------------
| | |
| | |
| | |
| | B |
| | |
| | |
| A |--------------------|
| | |
| | |
| | C |
| | |
| | |
-----------------------------------------
I know I can do this by closing C and reopening it after splitting B. Is there a simple way to do this where I don't have to close buffers and I can rearrange the windows directly?
You wouldn't "close" the buffer C, only the window that displays it.
Vim has dedicated normal mode commands for:
switching a window and the next one in a row or column,
rotating the whole window layout,
pushing a window to the far top, far right, far bottom, and far left,
but it doesn't have one for moving a window to an arbitrary point so, assuming the window you want to move has the focus, the command should look like this:
:q|winc w|sp c
which is not too shabby. You might be able to find a plugin that provides the level of control you are after on https://www.vim.org.

vim: "extend" window into next window

Let's say I have this layout in vim:
+-----+-----+-----+
| | | |
| a | | |
| | | |
+-----+ c | d |
| | | |
| b | | |
| | | |
+-----+-----+-----+
is it possible to end up with this layout:
+-----+-----+-----+
| | | |
| a | c | |
| | | |
+-----+-----+ d |
| | |
| b | |
| | |
+-----+-----+-----+
like an "extend right" command ?
PS. Don't tell me to use ctrl-w J on b then ctrl-w L on d, my layout is actually more complex then this. I'm really looking for an "extend right" command if it exists.
This is hard to implement as a feature since there can be a lot of edge case scenarios to consider, also why vim doesn't do this natively.
If you don't like the option of using ctrl-w J on b then ctrl-w L on d then the simplest approach would be to close the c split and then open a new vertical split on a and open the buffer / file within it that you desired.
This is brittle, but probably better than nothing!
function! ExtendRight()
let l:start=winnr()
exe "normal \<c-w>l"
let l:shrink=bufnr('%')
close
exe "normal " . l:start . "\<c-w>w"
exe "normal \<c-w>k"
vsplit
exe "b " . l:shrink
endfunction
You can map it with nnoremap <c-w>e :call ExtendRight()<CR>.

is there a way to move vim windows in this way?

I have four windows like this:
| | | |
| A | | |
|_________| C | D |
| B | | |
| | | |
So, how can I change them into this way?
| | |
| A | C |
|_________|______|
| B | D |
| | |
the
ctrl+W/J/K/L
thing is always moving the window to the far other side, I can't use them to do this.
Thanks!
what I can think of is two steps:
move cursor to C, press C-W c to close the window
move cursor to D, press :sp #<enter>
The idea is, close one window(buffer), and reopen it in right place (by sp or vs).
glad to know if there is easier way.

How to move vertical split window to horizontal split, when there is an existing horizontal split?

In Vim I tend to open buffers in new vertical splits (with the occasional horizontal split). I keep my code to 80 chars wide, so this works pretty well on large monitors.
I often end up with this window arrangement:
---------------------
| | | | |
| | | | |
------ | A | B |
| | | | |
| | | | |
---------------------
At four or five columns wide, it can start getting a bit too narrow, so then I want to move the windows around so it looks like this:
----------------
| | | A |
| | | |
------ ------
| | | B |
| | | |
----------------
As far as I know, this is impossible to do by moving the windows in Vim.
The only way to get that window arrangement I've found, is to close window A, and then re-open A as a new horizontal split from window B.
Is that correct, or is there a way to move/re-arrange windows like that in Vim? Maybe a plugin?
I'm yet to find anything, so I thought I would ask because I find the opening/closing of windows anoying and breaks my flow.
FWIW, I find the Ctrl-W + J / Ctrl-W + K shortcuts useless, because they make the new horizontal split as wide as the whole screen, rather than splitting with the neighbouring window. I.e. Ctrl-W + J would give me this:
----------------
| | | |
| | | |
------ | A |
| | | |
| | | |
----------------
| |
| B |
----------------
Which is generally never what I want.
If anyone has some ideas, let me know!
There's a plugin that can do exactly what you want. Here's the link : https://github.com/fabi1cazenave/suckless.vim.

Difference in operation while using Macrocontent in Normal Mode in VIm/gvim (Delete a Specific Column)

Defined a macro
let #a='$F|vF|<80>kr^V5jd'
Sample Input File
+--------------------+---------+---------
| Name | S1 | S2
+--------------------+---------+---------
| A | -4.703 | -2.378
| B | -3283.2 | -3204.5
| C | 8779 | 7302
| D | 22078 | 18018
+--------------------+---------+---------
When i'm using it as macro, its doing 1 task
:%norm #a
Result 1
+--------------------+---------+---------
| Name | S2
+--------------------+---------
-2.378
-3204.5
7302
18018
---------+---------
when try to do the same operation by
:%norm $F|vF|<80>kr^V5jd on the same file
it is doing different task
Result 2
| D | 22078 | 18018
+--------------------+---------+---------
Is there any special care we need to take while handling Visual Block Content Macros In Normal Mode ?
Is there anything wrong.
Actually, what i was trying to do was to remove the S1 Column, can any one help in that way!
Desired Output
+--------------------+---------
| Name | S2
+--------------------+---------
| A | -2.378
| B | -3205.5
| C | 7302
| D | 18018
+--------------------+---------
Thanks
This is what I got:
gg
f+
Ctrl-v
Shift-g
;;
h
d

Resources