10
6
This is a usability problem that happens often to me:
I open a read-only system file with vim, even editing it, because I'm not attentive enough, or because the vim on the system is badly configured. Once my changes are done, I'm stuck having to write them in a temporary file or losing them, because :w! won't work.
Is there a vim command (:W!!!) that allows you to write the current buffer as a super-user? (Vim would ask for your sudo or su password naturally)
Related: How does the vim “write with sudo” trick work? at SO
– kenorb – 2015-08-20T16:40:50.660related questions (not quite exact duplicates): http://superuser.com/questions/23428/vim-sudo-vim-bad-idea .. http://superuser.com/questions/106865/how-can-i-setup-an-alias-in-bash-for-sudo-vim-filename-as-sim-filename .. and from SO, http://stackoverflow.com/questions/1005/getting-root-permissions-on-a-file-inside-of-vi
– quack quixote – 2010-05-26T20:00:36.4201The SO is definitely a dupe, however the two SU questions address a separate problem solved with the
sudoedit
command. This question is more focused on forgetting to type it in the first place and elevating after starting the editor. – heavyd – 2010-05-26T20:22:32.150