~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, 13 days ago
Updated
9 months ago
Labels
No labels applied.

~razzi 10 months ago

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

~razzi 9 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 9 months ago

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