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.

Thomas
  • 6,242
  • 8
  • 26
  • 32
Schiem
  • 493
  • 1
  • 4
  • 5

3 Answers3

75

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
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 :)

m0dular
  • 1,231
  • 7
  • 8
  • 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 – avimehenwal Mar 05 '21 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.

jdhao
  • 606
  • 12
  • 29