In a regular shell:
$ env | grep -i vim
EDITOR=vim
After using :shell
$ env | grep -i vim
EDITOR=vim
VIMRUNTIME=/usr/share/vim/vim80
VIM=/usr/share/vim
MYVIMRC=/home/martin/.vim/vimrc
So it looks like Vim sets the VIMRUNTIME
, VIM
, and MYVIMRC
environment variables. Of those, VIM
seems the most reliable to me (you may not have a vimrc or even vim runtime).
You can also set your own environment variables:
:let $HELLO = "test"
:shell
$ echo $HELLO
test
This is especially useful to communicate info about the buffer you're editing; for example:
:let $VIM_FILETYPE = &filetype
:let $VIM_FILENAME = expand('%:p')
Will show up as something like:
VIM_FILETYPE=go
VIM_FILENAME=/home/martin/a.go