It’s easy
:w !sudo tee %
Why do you do that?
: vim insert model
w Write a file.
!sudo All shell sudo command.
tee The output of the vi/vim write command is redirected using tee.
% Triggers the use of the current filename.
原文链接:https://www.f2er.com/bash/389871.html