When I open a file of a given filetype I want it to split into two windows with the cursor in the bottom window. I can get this to work when opening the file from an existing vim session. But when I open the file in vim from the command line the cursor always starts in the top window.
I made a simple file, split.vim, to demonstrate what is happening (in my real case I use
autocmd FileType but this simpler case also reproduces it:
If I open vim with
vim -u split.vim it splits as expected, but the cursor is in the top window.
However, if vim is already running and I do
:source split.vim it does the same split, but the cursor is in the bottom window.
How can I get vim to split with the cursor in the bottom window, even when first opening vim?
I've also tried adding
wincmd j after making the split, but the result is the same.
Again, my actual use case uses
autocmd for a given filetype, but the above is easier to test with no vimrc. The
autocmd case has the same results. If I open a file when opening vim the cursor remains in the top window. But if I open a file of the specified filetype the cursor jumps to the bottom window.