I discovered this trick while trying to do some quick investigation in Vim, and not wanting to have to leave the editor, found a way to quickly replace Python code (or anything you can pipe to an external command) with it's output in Vim. What you do is, write the code inside a buffer, then select it in visual mode. Once it's selected, press : and you will get Vim's :'<,'> range, which means all the text between the beginning and end of the visual cursor.