VIM: Saving with sudo, without opening with sudo

It happens all the time. You open a file in VIM, you make three and a quarter trillion changes, and then realize you needed sudo but didn’t use it when you opened the file. What do you do? Well, if you might save the file under a new name, then quit, delete the original and rename the new file with the original name. It works, but its really annoying. Luckily there is a cool trick in VIM that lets you save with sudo, even after having opened a file without it. Here it is. ...

August 20, 2013 · 2 min · 262 words