39

Vim 8.1 added the :terminal command, which opens up a new bash terminal as a split. However, it always seems to be a horizontal split, and I prefer vertical splits. Is there a way to open a terminal as a vertical split without using:

:vsp
:terminal
<c-w>j
:q

Alternatively, is there a way I could add it as a command in my .vimrc, like so:

command Vterm :vsp | :terminal | <c-w>j | :q

The command above chokes on trying to execute <c-w>j, opens a new vim split with the following:

executing job failed: No such file or directory

Just having:

command Vterm :vsp | :terminal

Works fine, but leaves the original split.

3 Answers 3

74

You can use the :vert[ical] command modifier:

:vert term

:vertical works with any command that splits a window, for example:

:vert copen
:vert help vert
1
10

I'm not sure about regular vim, but the help says the ++curwin option doesn't split the current window. So you should be able to do something like:

:vs|:term ++curwin

Or you could use Neovim and just do :vs|:terminal or :vs term://bash :)

1
  • terminal command which I want to run accepts multiple CLI arguments, is it possible to pass multiple argulemnts with this syntax? I tried :vnew term://lein repl but it doesnt seems to works!!!? Also, I want to run this vim command from my ftplugin vimrc Mar 5, 2021 at 23:09
2

For neovim, to open a vertical terminal, the following work:

  • :vnew term://bash
  • :vsplit term://bash
  • :vnew term://zsh
  • :vsplit term://zsh

More documentation can be found by using :h :terminal inside neovim.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .