i have set f2 prompt key map <f2> :w<cr>:! d:\python34\python %<cr>
,when open python file in vim , press f2,the python file executed .for simple example, here python file , opened in gvim .
now can't input other python lines ,only thing can see result , hit key close window. want : when press f2, (the python file opened in gvim) ,the python console pop up,and files in python file copied python console automatically,and can go no input lines such obj().hello
in python console or go on edit in gvim ,i lazy man ,the gvim , python console opened waiting serve me , can write vim scripts achieve target? command :!d:\python34\python -i %
works fine ,i got ouput there still problem remain, 1)when command
:!d:\python34\python -i %
works ,the gvim window frozen , can't drag mouse see codes in vim. 2)there no python codes in python console wiondow
so if program full of many lines ,and can't remember previous content ,worse still, gvim window frozen ,how can codes?
avoid blocking
to make call asynchonous (to avoid gvim blocked during python session), use windows-specific :!start
command:
nnoremap <f2> :w<cr>:!start d:\python34\python -i %<cr>
list teh codez
i don't know whether possible list passed source code interactive python debugger. can print file contents before starting it:
nnoremap <f2> :w<cr>:!start cmd /c type % && d:\python34\python -i %<cr>
additional tips
- you should use
:noremap
; makes mapping immune remapping , recursion. - as mapping works correctly normal mode, use
:nnoremap
(or extend support visual-mode selections, too).
Comments
Post a Comment