--- Bram Moolenaar <[EMAIL PROTECTED]> wrote: > > Xavier de Gaye wrote: > > > Assuming the current buffer is the file 'foobar' in the current > > directory. After running the following Vim commands: > > > > :python import os > > :python os.chdir("subdir") > > > > the current buffer name is not changed as it is when you run > > the Vim command ':cd subdir' (but the output of ':pwd' is Ok), > > and when the following command is run afterwards: > > > > :write > > > > Vim writes the buffer to the file 'subdir/foobar', instead of the > > original file. > > > > This happens with Vim 7.0 compiled with Python 2.5. > > Well, you should not use Python to change directory. But it may happen > unintentionally... Checking the current directory after each ":python" > command is a bit inefficient, but that's probably what needs to be done > then. An alternative is to always chdir back to where we were to undo > the side effect of the Python command.
I am trying to use Vim as a python interpreter. So, I have mapped: :map <F4> :exe "pyfile " . expand("%")<CR> I edit some python stuff in a foobar file, and hit <F4> to run it. When the foobar file content is: import os os.chdir("subdir") I run into the above problem. It is probably safer to run python as: :map <F4> :exe "!python " . expand("%")<CR> But you lose the capability to do some investigation on the variables contents after the script has run. Xavier -- http://clewn.sourceforge.net gdb support in Vim