DEV Community

Discussion on: The Vim Trick Which Will Save Your Time and Nerves

Collapse
 
gnu profile image
Gnu's Not Unix • Edited

I use this map:

cnoremap WW w !sudo tee > /dev/null %

However, I prefer to edit files with this alias:

alias svim='sudoedit'
Collapse
 
gcorrel profile image
gcorrel

Well, I decided to follow you here just so, I can learn more from you. I'm a Software Developer by the way.

Collapse
 
atomicwrites profile image
David Castro

Just a warning for anyone that uses this, sudoedit or sudo -e makes a temporary copy of the file and then moves it on top of the real file when the editor exits. Which means that writing your changes doesn't actually modify the file, which caused me much head banging because no matter what I did I'd get the same error since I was making changes that were buffered in sudoedit until I closed my editor, but I was retrying after just writing the change.

Collapse
 
ploppy1337 profile image
ploppy

Oh wow that‘s stupid... not very usefull.