Search code examples
vimj

Run J script as if it were line-by-line entered into the interpreter


Is there a way to run the script as if it were typed into the interpeter? The benefits are that I don't need echos everywhere, the work done is saved as a file, and I can use vim to do the editing. Example:

example.ijs

x =. 1
x + 3

terminal

   x =. 1
   x + 3
4

If not, I'll write a vimscript that can do the above then share them here. The advantage of a vimscript solution is that I could have commands to run the entire file, the current line, the current selection, everything up to and including the current line, or whatever else is useful.

Related but not a duplicate: How to call J (ijconsole) with a script automatically


Solution

  • Use loadd rather than load to run the script and display the lines and results.

       loadd 'example.ijs'
       x =. 1
       x + 3
    4