How to open a new window below a split created by vimdiff?


How to open a new window below a split created by vimdiff?



If, at a command prompt, I run

vimdiff file1 file2 

I get a vim instance that has two files open side-by-side, something like this:

╔═══════╤═══════╗ ║       │       ║ ║       │       ║ ║ file1 │ file2 ║ ║       │       ║ ║       │       ║ ╚═══════╧═══════╝ 

This is very nice, but sometimes I want to open a third file to look at. I don't want to create another vertical split, because otherwise the lines will be so short I'd be scrolling horizontally all the time just to read them. But occupying a few lines at the bottom of the screen wouldn't hurt. So, how can I go from the above to the following:

╔═══════╤═══════╗ ║       │       ║ ║ file1 │ file2 ║ ║       │       ║ ╟───────┴───────╢ ║     file3     ║ ╚═══════════════╝ 

I've tried using :sp file3, but I just end up with this (supposing I ran the command while the cursor was in file1):

╔═══════╤═══════╗ ║ file3 │       ║ ║       │       ║ ╟───────┤ file2 ║ ║ file1 │       ║ ║       │       ║ ╚═══════╧═══════╝ 

Thanks in advance for your help!




vim mapping :w with a shell command

1:



Is it possible to display Indentation guides in Vim?


Does omnicppcomplete support typedef syntax


How do I get the VIM matchit plugin working with ColdFusion and HTML?

2:



How to delete bookmarks in NERDTree (Vim)?
If you've already opened :sp file3 as in your last example ^WJ will move an existing window where you want it to go..
how to map keys for popup menu in vim


3:


To expand on @fgm's answer, If you type this command, you can auto complete the file name you want to edit like in a normal :edit:.
:bot split +edit thirdfile.cpp 
But to avoid having to type all that, you can create a "User defined command" like this:.
:command -complete=file -nargs=* Third bot split +edit <args> 
Now you can just type :Third to create the third window at the bottom of the screen with the file you want to edit, for example:.
:Third mythirdfile.cpp 
Notice that you can auto complete just like with a normal :edit.. And of course you can change the name of the command to something else if you don't like :Third, just keep in mind that it must start with a capital letter.. For more info type :help user-commands and :help 40.2.



85 out of 100 based on 55 user ratings 205 reviews