开发者

make python os.chdir follow vim autochdir?

开发者 https://www.devze.com 2023-01-13 05:07 出处:网络
I use the autochdir option in VIM and I also utilize VIM\'s built-in Python interface. Is it possible to have the current directory for the built-in Python interpreter follow VIM\'s autochdir. For exa

I use the autochdir option in VIM and I also utilize VIM's built-in Python interface. Is it possible to have the current directory for the built-in Python interpreter follow VIM's autochdir. For example, when I am editing a Python file, VIM's autochdir option puts me in the same directory as the edited file as far as VIM is concerned, but I still have to manually

 :py os.chdir(directory)

from the VIM command li开发者_如何学Gone in order to get the Python interpreter to recognize the same directory that VIM has.

Is this possible? I'm using VIM 7.2 on Windows.


You could try putting in vimrc

autocmd Filetype python py os.chdir(directory)

which means that whenever a python file is read or written, it executes this command.

0

精彩评论

暂无评论...
验证码 换一张
取 消