I'm using vim 8 and I set a shortcut to open a terminal in my vim.

nnoremap <F5> :wa<CR> \| :term ++kill=term<CR>

It works except that it opens a terminal vertically as below:

|        |some file|
|        |terminal |

What I need is to put the terminal on the right side:

|        |         |        |
|nerdtree|some file|terminal|
|        |         |        |

How can I change the shortcut of <F5> to achieve this?

  • 1
    Have a look at the different command modifiers, starting at :h :vertical – Christian Brabandt Apr 23 at 10:21

Use the :vertical and :botright modifiers.

nnoremap <F5> :wa \| vertical botright term ++kill=term<CR>


nnoremap <F5> :wa<CR>:vertical botright term ++kill=term<CR>

(Also note that you need one of <CR> or \|, not both. Your original command ends up executing the Normal mode | motion, which moves the cursor to the first column, followed by a space that moves it to column two.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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