I am trying to use MacVim's :terminal to execute some commands, but for some reasons I fail to make even the simplest functions work.

Here are some examples:

    :function TryF()
    :   execute 'terminal ++rows=10 print "Hello"'

gives me as output "executing job failed: No such file or directory".

    :function TryF()
    :   execute 'terminal ++rows=10 cd %:h && ls'

gives me no output at all, while if I reverse:

    :function TryF()
    :   execute 'terminal ++rows=10 ls && cd %:h'

I get a weird bunch of errors. I am using a macbook air. Any clues what might be going wrong?

BTW: If I pass only the command 'ls' to terminal I do not get any error.. I execute the functions from vim with :call TryF().

1 Answer 1


You need to pass :term the ++shell option.

From :help :term:

++shell: Instead of executing {command} directly, use a shell, like with :!command.

This should work:

function! TryF()
    terminal ++rows=10 ++shell cd %:h && ls
  • 1
    Great! That does the trick, and it educated me on the difference between shell and terminal :)
    – Kore-N
    Dec 23, 2020 at 17:08

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.