Skip to content

Instantly share code, notes, and snippets.

@nhooyr
Last active January 29, 2016 01:52
Show Gist options
  • Save nhooyr/c83bdc411de73520a78b to your computer and use it in GitHub Desktop.
Save nhooyr/c83bdc411de73520a78b to your computer and use it in GitHub Desktop.
nnoremap <silent> <leader>ws :call SudoWrite()<CR>
function! SudoWrite()
let undofile = fnameescape(substitute(expand("%:p"), "/", "%", "g"))
exec "wundo" . &undodir . "/" . undofile
execute ":write !sudo dd of=" . shellescape(@%, 1)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment