* Dahong Tang <[email protected]> [2013-08-08 04:16]: > On Wednesday, August 7, 2013 8:48:56 PM UTC-5, Ben Fritz wrote: > > On Wednesday, August 7, 2013 8:42:20 PM UTC-5, Dahong Tang wrote: > > > I have a system configuration file that belongs to root. > > > I can edit this file in nano using the command sudo nano, > > > but I can't edit it using sudo vim - it's always read-only > > > in vim, unless it is opened by root. Does anyone know why > > > is this? Is there an option in vim that would allow the > > > file to be edited via sudo vim, just like in nano? Thanks! > > > > I don't know why that is. Can Vim write it anyway? > > I.e. do you just mean that Vim has its own 'readonly' > > option set, or can Vim actually not write the file? > > I think vim has its own readonly option. If I use :w!, > then it would override the readonly option, and the file can > be edited subsequently with sudo vim. I don't understand why.
nano doesnt show any permissions, vim does. end of story. (we simply have a description of a problem lacking information.) so.. as root create a file in /tmp and make it only readable for root: $ FILE=/tmp/testfile $ sudo touch $FILE $ sudo chmod 400 $FILE now compare what nano and vim tell you: $ sudo nano $FILE $ sudo vim $FILE nano doesnt say anything.. it's running as "root". vim, however, checks the permissions and tells it has got the rights to write this file or not. of course, a ":w!" finally make used of root's priviledges to write anything. i prefer vim's way. :) Sven -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
