~razzi/dev-env#2: 
shortcut for :w !sudo tee % and quit

When opening a readonly file, it's a hassle. Would be nice to have a single command to acknowledge it's readonly and edit it anyways, like a shortcut to do the tee % trick.

Status
RESOLVED CLOSED
Submitter
~razzi
Assigned to
No-one
Submitted
1 year, 8 months ago
Updated
1 year, 5 months ago
Labels
No labels applied.

~razzi 1 year, 6 months ago

A decent starting point is cmap w!! w !sudo tee > /dev/null %

~razzi 1 year, 5 months ago

for edit:

cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!

for write and quit:

cnoremap w!q execute 'silent! write !sudo tee % >/dev/null' <bar> :q

~razzi REPORTED CLOSED 1 year, 5 months ago

Register here or Log in to comment, or comment via email.