In troubleshooting vi, I noticed on my Ubuntu installation running the command sudo env | grep HOME returns the home directory of the user that runs the command (/home/USER). But I noticed on my Linux Mint installation running the command sudo env | grep HOME returns /root. I have looked at /etc/sudoers on both computers and they are identical except for a Defaults mailto= entry. They both have Defaults env_reset. How does sudo determine how to set the HOME environment variable? I've seen elsewhere (https://unix.stackexchange.com/a/174587/471273) that sudo -V tells you which environment variables are preserved, but on both computers it just told my the sudo version and the plugins it was installed with. I also see in the sudo man page this section which makes me thing I need to ask how to view the security policy which I don't know how to do.
-H, --set-home
Request that the security policy set the HOME environment
variable to the home directory specified by the target user's
password database entry. Depending on the policy, this may
be the default behavior.
This is causing problems with loading .vimrc when I run vim as sudo. I could copy the .vimrc to the /root directory, but I am curious about this behavior and about sudo.