Changing the size of the split screen in vimdiff - vim

I only know two commands for dealing with vimdiff:
Ctrl-w Ctrl-w switches windows and Ctrl-w = makes the two windows equal width if they became uneven due to, for example, resizing the terminal.
How can I make the left screen much larger than the right, for instance?

You can use any windowing command in vimdiff, for example CTRL-w < to make the left window one column smaller. This can also be combined with a count, for example CTRL-W 5> to make the right window 5 columns smaller. Consult the help page with :help CTRL-w to get a list of window commands.
Additionally, you can use the mouse to change the size of the windows by clicking the boundary between both windows and dragging it into a direction. You might have to enable mouse support by issuing :set mouse=a first.

Related

How to fast change focus between tabs in neovim?

How to fast change focus between windows in neovim? I dont know how to make it.
A quick reference from usr_08.txt
CTRL-W h move to the window on the left
CTRL-W j move to the window below
CTRL-W k move to the window above
CTRL-W l move to the window on the right
CTRL-W t move to the TOP window
CTRL-W b move to the BOTTOM window
If you're a new user (and have done vimtutor), I highly recommend going through the user manual (or at least skim through it, so that you learn the basics of Vim) - :h user-manual.
Both for Vim and NeoVim, why don't you give a try to this plugin I've created to allow easy movement between, and "management" of, windows and tabs?
I you go to that page, you'll see I've included a GIF showing the keys I press and what they do. Essentially you press leader+w to enter a "window management"-mode which interprets any key as if it was preceded by Ctrl-W.

Vim, split window have only 1-line-size

I have the problem with splitting windows. If I open a file with :split the size of the new window includes only one line. I don't know why.
Is there a way to resize the window in vim as I need it?
jump into the window you want to resize (ctrl-w ctrl-w OR ctrl-w direction-arrow), then hit ctrl-w followed by [number followed by] + (or - if you want to decrease the size)
the number is optional and indicates how many "units" you want to enlarge the window by, defaults to 1 if not specified
Or just hit ^W= to make all windows roughly same-size.
Also, :se mouse+=a should enable you to just drag the dividers with the mouse, even on terminal emulators across a GNU screen session.

Vim window resizing

I split my windows in Vim horizontally. But after I split, the new window occupies half of the original window size, I want to change this and make sure the new window occupies almost the entire old window.
Basically if I open three files using horizontal split in Vim, I should see three status bars at the bottom of the screen the third file occupying the rest of the screen. The files as I already know can be navigated through Ctrl+W+arrow keys. So if I navigate to second file now, I should see one status bar at the bottom and one status bar at the top.
Kindly let me know how to configure the same. I looked up online all I could find is options to dynamically change the size or resize, but I want static one-time config (for example, in vimrc or bashrc).
If you set the winheight option to 999, the current window occupies as much of the screen as possible, and all other windows occupy only one line (I have seen this called "Rolodex mode"):
set winheight=999
You can type in command mode :res[ize] +N or :res[ize] -N where N is the amount in which your window will grow or shrink respectively.
Go to point 6 (Window resizing) http://vimdoc.sourceforge.net/htmldoc/windows.html but the article has everything on windows management in VIM
Hope this helps!
You might prefer just using vim tabs, which work rather like how you described.
Try this:
vim -p file1 file2 file3
Then use :tabn and :tabp to cycle fwd and back through the tabs.
I also like this mapping in .vimrc to use ctrl-l and ctrl-h to cycle fwd and back respectively:
noremap <C-h> :tabp<CR>
noremap <C-l> :tabn<CR>
Command for split window:
:[N]sp[lit] [++opt] [+cmd]
Where N is height of new window. Default is to use for half the height current window. Same thing for vertcal splitting:
:[N]vsp[lit] [++opt] [+cmd]
N is width for split window.
And so on:
[N]new, [N]vnew
For details read the
:help split
But I can't understand why you do not use buffers?

Specifying width for :vsplit in vim

Is there any way to specify a width when doing :vsplit?
Also, is there a way to increase or decrease the width on a vertically splitted window? Ctrl-w + and Ctrl-w - seems to be working on only horizontally split windows.
According to :help :vsplit, it takes an optional numeric argument as a prefix, e.g., :80vs. Try it out!
Edit: I guess I forgot to mention. You can control the width with Ctrl-W < and Ctrl-W >
For more info, read the manual at :help windows
Ctrl-W n < works, replace n with the number of steps you want to move.
You can also use for example 80| to set your current split width to 80 columns
If you want to fix the adjusted windows width, be sure the cursor is placed inside it and set the boolean
:set winfixwidth
This prevents from unwanted automatic resize of the such locked window width if some other window command like CTRL-= ("make all windows equal") is applied.
:set nowinfixwidth with the cursor placed inside the appropriate window disables the lock.
:mksession stores the window arrangement as calling vim again from the command line likevim -S Session.vim & restores it.
Hope this helps...
Also:
:vs
:vertical resize 30
and:
:sp
:resize 30
I have an Alt+E binding for a vertical file-explorer pane 60 chars wide:
:vs +Explore<CR>:vertical resize 60<CR>
Admittedly, I didn't know about the simple :60vs or :60sp thing in Luis' answer when I wrote that macro.

Vimdiff current line compare

In Beyond Compare, the line you currently have selected is compared on top of each other at the bottom of the window. Is there any way to accomplish this in vimdiff?
Short answer No.
Vim does not have a built in way to do that. You would have to write a plugin that would split two more windows on the bottom, re-size them to 1 line. I tried doing it manually but it didn't keep one of the windows in sync while scrolling.
My work around is to use CTRL-W J to move the window to the bottom and then CTRL-W L to bring it back to side by side comparison.
see help: window-moving for details

Resources