Vim Tutorial 17. File Opening Options +n, +/pattern/, readonly R
Vim Read Only. Web where is it located? Web as on other vi/vim versions, you can use :w!
Vim Tutorial 17. File Opening Options +n, +/pattern/, readonly R
Which you could map to :w!! Web as @rob already mentioned, you can only do this if you have write access to the directory containing the file. Web the file will be saved but remains opened in vi/vim for more editing or reading. You will need to add to your vimrc an autocommand which will be executed every time you read the file and will be used to set the 'readonly' option on the file:. For example, if you have set the. When using :w! the 'readonly' option is reset for the current. We can now exit normally by typing esc :q! Web where is it located? :w !sudo tee > /dev/null %. Web as on other vi/vim versions, you can use :w!
Web if you only make vim unable to edit the file, other ways of editing will still be in place so if the file is not to be changed, it should have the rights set properly. Which you could map to :w!! In this case the command is sudo tee % >/dev/null. :w !sudo tee > /dev/null %. Web you can do it in pure vimscript, without having to use an external tool like sed: Web as @rob already mentioned, you can only do this if you have write access to the directory containing the file. The special symbol % means the filename of. Ask question asked 12 years, 9 months ago modified 12 years, 9 months ago viewed. We can now exit normally by typing esc :q! For example, if you have set the. When using :w! the 'readonly' option is reset for the current.