Save as root in vim

  • If you edited file as non privileged user and want to save it bypasing ‘permission denied’ you have to use this snippet:

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

    Add this to your ~/.vimrc and use :w!! to save file with sudo…