:terminal spawns a new shell in a Vim window, so you can see a program compiling or producing some output at the same time you edit another normal buffer. Also, by pressing
<CTRL-W>N, Vim can operate on the read-only terminal buffer, with yanking, Vim navigation, etc.
:shell also spawns a new shell, but this is a full terminal window shell (it is not in the Alternate Screen as Vim) that won't interacact with the underlying Vim. One can only switch back to Vim by terminating that shell. Unlike
:shell is not a Vim extension as it is in the POSIX specification of Vi (indirectly, since it is an Ex command), and so a Vim compiled with minimal features (vim-tiny in Ubuntu and Debian) will only have
:shell is very similar to
<CTRL-Z>, which uses the shell's job control to suspend Vim. But there are differences:
- Suspending is impossible in a terminal without a controlling shell (e.g.
xterm -e vim).
:shell spawns a new shell, which does not have access to Vim's parent shell local values, such as history and variables, whereas each suspenion always brings the same shell back. Indeed, you can toggle between the same shell and Vim with