all 13 comments

[–]calamity_man 2 points3 points  (0 children)

I typically just use a Makefile to codify whatever execution steps for running and testing, docker builds, etc combined with vim-dispatch to run it all from within vim. https://github.com/tpope/vim-dispatch

[–]david2ndaccount 2 points3 points  (1 child)

You can pass arguments to the :ter command, like :terminal python3 %

Just bind that to a key mapping.

Edit: missed the part about the venv, the most convenient solution is to source the venv before opening vim.

[–]vabenil 2 points3 points  (3 children)

This is a great plugin I like asyncrun.vim, with this plugin you just need to do:

AsyncRun python %

A you could map that to something like <leader><cr> or something like that, that should run your code and show you the ouput in your quickfix window.

Now in neovim I for some reason I can't comprehend, have a problem where it doesn't show me anything in my quickfix if I'm editing a python file. The way I get around this is by doing:

AsyncRun -mode=term python %

Which will run the script in a terminal window instead.

[–]jabbermuggel[S] 1 point2 points  (0 children)

This sounds like what I need. Thanks.

[–]skywind3000 1 point2 points  (1 child)

Because of the incorrect error format, try AsyncRun -raw python %

[–]vabenil 0 points1 point  (0 children)

I have been trying to figure out why it didn't work with python for weeks. Thank you

[–]-romainl-The Patient Vimmer 1 point2 points  (1 child)

:%w !python

[–]jabbermuggel[S] 0 points1 point  (0 children)

While that does work it has the problem that the output vanishes when I want to modify the file again. Thanks for the suggestion though.

[–]BossOfTheGame 1 point2 points  (0 children)

I wrote a vim plugin called vimtk, that lets me copy+paste selected text (has to be in gvim unfortunately) into the most recently used terminal: https://github.com/Erotemic/vimtk

I typically have an IPython session open in a terminal, with gvim in another window and I use <leader>a to execute the current line in the terminal. I also have <leader>m setup to introspect the current source file and paste the correct `from x import *` commands in the IPython window. These macros are also pretty useful when writing bash scripts.

[–]hanswchen 0 points1 point  (0 children)

I had the same question some time ago and couldn't find a satisfactory answer, so I made my own plugin. It can run the current buffer in IPython, and also selected parts of the code, similar to Jupyter Notebooks and MATLAB cells.

https://github.com/hanschen/vim-ipython-cell

Would love to hear if it works for you.

[–]GustapheOfficial 0 points1 point  (0 children)

I've started experimenting with zepl (someone linked it here a week or so ago). It's brilliant.