Is there any way I can concatenate a command after :terminal?
For example :terminal | <some_other_vim_command> will pass | <some_other_vim_command> to the terminal that just opened, but how can I prevent that from happening?
Is there any way I can concatenate a command after :terminal?
For example :terminal | <some_other_vim_command> will pass | <some_other_vim_command> to the terminal that just opened, but how can I prevent that from happening?
Not all Ex commands allow | to be used as a command separator, some Ex commands want to take | as an argument.
The common workaround is to use :execute to wrap those commands that do not allow | as a command separator.
See :help :bar or :help :| for more details and a list of commands that take | as an argument:
These commands see the '|' as their argument, and can therefore not be followed by another Vim command:
:argdo:autocmd- ...
:normal- ...
:windo:write !:[range]!
Most Ex commands (such as :!) that take a shell command as an argument will not allow | as a command separator, since shell commands typically use | as a pipe between shell commands, so they'll pass the | literally to the shell.
Note that :terminal is not on that list (as of Vim 8.2.598) but that's just an omission in the documentation and @ChristianBrabandt offered to push a documentation patch to fix that in Vim.
The documentation in :help :| also mentions:
To be able to use another command anyway, use the
:executecommand.Example (append the output of "ls" and jump to the first line):
:execute 'r !ls' | '[
And :help :execute also mentions that type of usage:
:executecan be used to append a command to commands that don't accept a|.Example:
:execute '!ls' | echo "theend"
In your particular case, you can use:
:exe "terminal" | <some_other_vim_command>
:exe ":terminal" | another_vim_command– Christian Brabandt Apr 23 '20 at 11:28:h :bar. Will post a doc patch later. – Christian Brabandt Apr 23 '20 at 13:49