0

I write lot of snippets that needs to be evaluated in REPL . I can do this by copy paste or loading the entire file in REPL but its an overhead sometimes . What is the simplest way to pass a visual region to a repl in an interactive manner ?

I came across Vim: Run selected code in a persistent REPL-environment .

However what I need is simple way to start a REPL from a VIM Visual selection with stdin as the Visual Input .

I need to understand how the visual buffer can be piped into python with no filtering back or handling the output .

For example

Some Other Code

Class Foo():
   pass

Some Other Code

I need to be able to select only Class Foo() and enter the REPL with Foo visible in the namespace of the REPL . I have seen many variants like filter back the output etc . But this is more for learning Python Snippets etc and I prefer writing in VIM as opposed to REPL .

PS This Question Is Actually for Python:

I figured that this will work to get a python REPL with stdin in bash :

vnoremap <F6> :w! /tmp/tmp.py  <bar> !python -i /tmp/tmp.py<CR> 

Looking for a generic way to solve this issue . I believe the core of the problem lies in Vim having issues with dealing with processes ?

There is also a plugin like : https://github.com/zweifisch/pipe2eval

Community
  • 1
  • 1
Nishant
  • 20,354
  • 18
  • 69
  • 101

1 Answers1

1

You should see if what you ask is this: vim-notebook which allows the user to keep a background process alive and to make it evaluate parts of the current document (and to write the output in the document). It is intended to be used on notebook-style documents containing pieces of code to be evaluated.

Thomas Baruchel
  • 7,236
  • 2
  • 27
  • 46