1

I have text in vim that I would like to save to pace where sudo privileges are needed. How to solve this when vim is started without sudo?

2

2 Answers 2

6

You can use:

:w !sudo tee %

as explained here: How does the vim "write with sudo" trick work?

Sign up to request clarification or add additional context in comments.

Comments

0

To put it in other words

Can I give sudo permission to already running process?

I don't think this is possible. I tried to find out if there is any way, but no. check this post.

Workaround :

You can use :sav <new/path/filename.extn> to save it some place where you have right permission (temporarily). Later open the vim process with super user permission this temporary saved file and save to the target destination using the above mentioned command.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.