Search code examples
vimsplittext-editorvimdiff

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!


Solution

  • Use

    :botright split 
    

    and open a new file inside.