Often forget the sudo directly with vim edit/etc files, and so on editing, save time only found no permissions.
OK, the way to save the curve is to first keep a temporary file, exit and then sudo CP back. However, in fact, the process can be done directly in Vim, which is the order.
Consult the VIM documentation (input: HELP:W), which will refer to the command: w! {cmd}, let vim execute an external command {cmd}, and then pass the contents of the current buffer from stdin.
Tee is a gadget that saves stdin to a file. and%, is the name of a read-only register in Vim, which always holds the file path of the currently edited file.
So executing this command is equivalent to modifying the currently edited file from the outside of vim.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Normal user vim Open file Edit and save as Root