how to bind the prompt key to 2to3.py?

允我心安 提交于 2019-12-25 03:22:42

问题


I have write a vimsrcipt to bind F3 key to change python2 file into python3 file.

map <f3> :w<cr>:! D:\Python34\python D:\Python34\Tools\Scripts\2to3.py  -w %<cr>

I feel that it should be improved for useage. It works in the steps:

step1: open the test.py( in the form of python2) in gvim
step2: press F3
step3: close the test.py( in the form of python2)
step4: open the test.py(now ,it is in the form of python3)

Now i want to make a little progress, when i press F3 ,the test.py will be changed into python3 form,not to reopen it.
How can i?


回答1:


You can avoid steps 3 and 4 either by explicitly reloading the file via :e:

nnoremap <f3> :w<cr>:! D:\Python34\python D:\Python34\Tools\Scripts\2to3.py  -w %<cr>:e<cr>

or by turning on

:set autoread

Again, you should use :noremap; and specify the proper mode (normal mode).



来源:https://stackoverflow.com/questions/25481506/how-to-bind-the-prompt-key-to-2to3-py

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!