I currently have the following abbreviation:

cnoreabbrev tright vert rightb terminal zsh

With this, :tright in normal mode will open a terminal buffer on the right side of the screen, which is great.

But I want to make it so that when I open a file it executes this command instantly and then moves the cursor to the file I wanted to edit.

$ vi <file> -c "tright | normal <C-W>h"

doesn't work and I tried various combinations of similar things, in .vimrc as well as just on the command line itself and it didn't accept it. I tried writing multiple functions and the like but couldn't quite get it figured out. It seems that after typing zsh everything is interpreted as an argument to that command.

More precisely, I just need to know what to type into the terminal so that:

  1. I see a vsplit, with the left window being the file I specified and the right being a terminal buffer

  2. When vim opens the cursor is in the left window

  3. All of this stuff only happens when I tell it to in the command line (not default/automatic startup)

Something along these lines is what I'm looking for:

$ vi <file> -c <something short here hopefully...>

^ for when I want to start in the file buffer in normal mode, then

$ vi <file>

^ for when I want to start in the terminal buffer, and, of course,

$ vi <file>

^ for when I don't want a terminal buffer.

Any amount of functions, statements, aliases, etc. in .vimrc are perfectly ok, as long as it can be called from the terminal with something that isn't too long to type.

2 Answers 2



vim filename -c "vert rightb term zsh" -c "wincmd h"

With additional command in vimrc:

command! VT exe "vert rightb term zsh" | wincmd p
$ vim filename -c VT

I would try

command! Tright vert rightb terminal zsh

And then:

$ vi <file> -c "Tright" -c "normal <C-W>h"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.