Write to a Read Only File

4 Points

Britt Gresham Britt Gresham

10 years ago

Whenever you open up a read only file you have to either reopen vim with sudo or remember a vim command to write out to a new file with sudo. This mapping expands:w!! to :w !sudo tee % > /dev/null

cnoremap w!! w !sudo tee % >/dev/null

Martínez Ortiz Saúl Axel

Martínez Ortiz Saúl Axel 6 years ago

It's useful to maintain your configs when editing sudo files.