How to view environment of process

Sometimes you might be curious to find out the environment variables and values of a running process.

This is easy to do with the ps command, by providing the PID of the process (say 9999):

$ ps eww 9999

The ps command on Linux relies heavily on the /proc pseudo filesystem to gather almost all of its information on processes. So, as you might guess you can get the exact same environment that ps prints from /proc. Just provide the PID, say 9999:

$ cat /proc/9999/environ

Tried with: Ubuntu 14.04

How to view environment variables in Vim

List of all environment variables in Vim.

When Vim is started, it grabs the environment variables of the operating system (like PATH) and it also sets it own internal environment variables (like MYVIMRC).

To see all the environment variables available inside Vim, type :echo $ and press Ctrl-D

To see the value that is currently assigned to a particular environment variable, for example $VIM, type :echo $VIM

For more details go here.

Tried with: Vim 7.3.46 on Windows 7 64-bit

Windows Environment Variables in Vim

All the Windows environment variables are read by Vim and they are available in Vim as Vim environment variables. Vim environment variables begin with the character $. Hence, the Windows environment variable name is prefixed with the $ character when it becomes a Vim environment variable.

For example, the Windows environment variable %USERPROFILE% will be available as $USERPROFILE inside Vim.

This post shows how you can list all the environment variables or view the value of a particular variable.