问题
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