- 论坛徽章:
- 0
|
现象 VIM Message: E45: 'readonly' option is set (add ! to override)
解决方法原因 The :w !sudo tee % command tells VIM to write the file (w) but run the sudo command first (!sudo) and read the writing of the file from standard input to standard output (tee) using the same filename as the one we’re editing (%).
And last but not least, if you don’t want to remember the syntax for this command, you can map the command in your ~/.vimrc file:- cmap w!! w !sudo tee % >/dev/null
复制代码 Now, if you forget to edit a file with sudo, you can simply type :w!! to fix the problem!
|
|