Search code examples
vimvi

How to change file permission from within vi


I sometimes open a read-only file in vi, forgetting to do chmod +w before opening it. Is there way to change the file from within vi?

Something like !r chmod +w [filename]?

Is there a shortcut to refer to the currently open file without spelling it's long name?


Solution

  • Just use

    :!chmod +w %
    

    in command mode. % will be replaced by the current file name.