How to Save a File in Vim Without Restarting with sudo
You opened a system config file in Vim without sudo, made changes, and hit :w to save. Permission denied. Retyping everything isn’t happening. The Solution: :w !sudo tee % From Vim’s normal mode, type: :w !sudo tee % This pipes your buffer through tee running as root: :w — write the current buffer ! —…