sudo write vim file code example
Example 1: vim sudo write
:w !sudo tee %
Example 2: vim sudo write
For Neovim: https://github.com/lambdalisue/suda.vim
"In init.vim
Plug 'lambdalisue/suda.vim'
Run :SudaRead
It will prompt for password when you next try to :w