Gary Johnson <[EMAIL PROTECTED]> 写于 2007-05-16 16:41:22: > On 2007-05-16, [EMAIL PROTECTED] wrote: > > Hi, vimmers: > > > > The line 1230 of editing.txt said: > > > > To change to the directory of the current file: > > :cd %:h > > > > This works for Vim 7.0 and before, but not for Vim 7.1. In Vim 7.1 when the > > pwd is the same as the directory of current file, the command will fail > > with E500. The failure will break the execution of a mapping, if one have a > > mapping to do :cd %:h and then continue to do something else. > > > > To reproduce the error, just at anytime, run :cd %:h twice. (I've got > > Windows gvim7.1.1, cygwin console vim 7.1.1) > > I would expect ":cd %:h" to give an error the second time it is > executed. Just to be sure, I repeated your experiment on 7.1, 7.0 > and 6.4 on Unix and 7.0 on Windows. I always got E500. Are you > sure that it "works" for you for Vim 7.0?
Positive, I've got a mapping which do :cd %:h then :grep, this mapping works since Vim 6.3, 6.4 and 7.0, this is the mapping I used "Everyday" and I cannot use Vim without it, then suddenly it breaks after I installed Vim 7.1. ---- Now I changed :cd %:h to :cd %:p:h and everything works. Anyway, I think there should be an option to disable E500, or "catch and throw". This is the Unix trend: if the caller feel necessary, a program should fail silently in order not to break a script.