Is there any way I can concatenate a command after
: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?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
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.
: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:
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.
: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
Example (append the output of "ls" and jump to the first line)::execute 'r !ls' | '[
: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>