1

I've been using Vim 6.3 (specifically, gvim) for years (and plain old vi for decades before that). One nice feature was that autoread would detect if the file permissions changed. I made use of that feature with the following autocmd,

autocmd BufWritePre * if &readonly | !p4edit <afile>

where p4edit is a shell script that, among other things, runs "p4 edit" on the file to open it in my Perforce sandbox and make it writable. This script would be invoked if I "w!" wrote the readonly file.

In Vim 6.3, vim knew from then on that the file was writable, but now with Vim 7.4, this is no longer the case. Subsequent write attempts still require "w!", and the p4edit script is reinvoked each time.

Likewise, if I "p4 submit"ed any files I had open in gvim windows, the next time I went to one of those windows, gvim would notice that the file was once again readonly.

Is there a way to get the old behaviour back?

  • This should also work in Vim 7.4. Are you sure that you have the autoread option set? – Martin Tournoij Aug 8 '15 at 11:27
  • Just checked, and yes, autoread is set @Carpetsmoker – Stefan Vorkoetter Aug 11 '15 at 18:53
  • 1
    It appears that the problem is that I needed set cpoptions-=Z. I guess that changed between Vim 6.3 and 7.4 – Stefan Vorkoetter Aug 14 '15 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.