preferred windows text editor?

Charles Sanders C.delete_this.Sanders at BoM.GOv.AU
Thu May 10 04:59:48 EDT 2007


Ant wrote:
> 
> What method of executing code snippets in a Python shell do other Vim
> users use? Other than just copy/paste?
> 

Not vim, but good old vi so should work in vim

1. Mark the start of the fragment, for exampls ms (to mark
with label s). Labels a through z are available.
2. Move to the end of the fragment.
3. :'s,.w !python     to send the fragment to the python
interpreter

Worked for me when I tried it a few minutes ago. I had never
bothered before - just copied/pasted.

Obviously, you can also mark the end, move to the start and
do something like :.,'ew !python  or mark both the start and
the end, or use line numbers, or labels plus offsets, or
searches, eg :/def/;+5w !python to search forward to the
next occurrence of "def" and send that line plus the next
five to the interpreter. Whatever works for you. The abbreviate
and map commands can be used to reduce the typing if you are
fanatical.


Charles



More information about the Python-list mailing list