Vasu Adari
Vasu Adari

Reputation: 908

Is there a way to switch to write mode if i had opened a file in read only mode in vim?

Sometimes i feel annoyed closing it from read only and opening it again in write mode to edit. If haven't opened a file with sudo permission and if incase i just want to switch that by some command within a vim. Is it possible?

Upvotes: 0

Views: 107

Answers (1)

Amit
Amit

Reputation: 20456

You can use the following command to save a file you edited in vim without the needed permissions:

:w !sudo tee %

Upvotes: 1

Related Questions