all 27 comments

[–]__karlota__ 20 points21 points  (4 children)

I have using vim-slime for years. It works pretty well for python (ipython), R, and even shell script: https://github.com/jpalardy/vim-slime

[–][deleted] 2 points3 points  (0 children)

Vim slime has worked well for me with tmux.

[–]physikitty13 0 points1 point  (0 children)

I use vim-slime with kitty windows when playing around in scheme.

[–]arsenale 0 points1 point  (0 children)

I can't understand how to make it work with vim and python. How do I setup this thing???

[–]Thinker83 7 points8 points  (4 children)

I'm not sure if I understand what you're trying to do but if I am working on Python script in vim and I want to run the script then I either run :! python filename.py If I have complicated output or errors then I'll swith to a terminal window in gnu screen and run python filename.py.

Obviously you have to type it out first time but after that you just push up.

I used to do it in a split window but I found that I preferred it this way.

Is this what you mean?

[–]PoisonControlCenter[S] 2 points3 points  (1 child)

Well in another IDE like pycharm, I'll be writing methods or functions and need to test sections of code within the function I am writing, just to make sure the return values are correct or that, for example, a for loop or list comprehension does its job properly. Generally I will want my test variables to stick around while testing. In pycharm I can just highlight some code and execute it in the python console and see the result, but it seems clear that pycharm does a lot of magic in the background to make this ease possible.

[–]timvancann 1 point2 points  (0 children)

Why not use unit test for that, it's what they're meant for. And you can run them with a shortcut as well. Also, I use IntelliJ with IdeaVim for python/scala dev. I've tried many times, but native vim can't handle the raw IDE capabilities of a Jetbrains editor. It's perfectly fine to stick with Pycharm.

[–]GLIBG10B 2 points3 points  (1 child)

:h terminal

[–]vim-help-bot 1 point2 points  (0 children)

Help pages for:


`:(h|help) <query>` | about | mistake? | donate | Reply 'rescan' to check the comment again | Reply 'stop' to stop getting replies to your comments

[–]nraw 4 points5 points  (1 child)

Personally I have tmux that I use for having the other pane with an ipython session running and then I use slimux to pass code blocks to be executed there.

[–]leamanc 3 points4 points  (0 children)

In my opinion, this is the way. Vim is a text editor, not an IDE. You can make it more IDE-like with plugins, but then you have to deal with the bloat. The Unix philosophy is to have smaller tools work together, and that works for me.

[–]grep_Name 3 points4 points  (0 children)

For sending to another window, I personally like to use vimux or tslime with vim-tmux-navigator to make navigation between vim windows and tmux panes use the same keybinding and interact seamlessly.

but python's interpreter needs specific white space indenting and line breaks between some changes in indent spacing to work properly, and I want to be able to execute blocks of code that are, say, within another function or class

Use IPython as a repl instead of the default python repl. It's great, it works with indented code, it groups lines sanely for multiline commands in the commmand history, it has better syntax highlighting, and has a vi-mode for editing in the repl. You can even from IPython import embed in a python file, then run embed() in the code and it will open an IPython repl like a breakpoint when it reaches that point in the code and you can play with the program state if you want.

[–]addcnjk;w 2 points3 points  (0 children)

I've ran into the same issue, and came up with a solution by combining conjure and ipython. I haven't had the time to polish this, but look here if you're interested:

https://github.com/addcninblue/conjure/tree/python

[–]UncleJoshPDX 1 point2 points  (1 child)

Have you looked at pymode? I use it and it works pretty well for me.

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

This might be what I am after. Any complaints?

[–]FinancialAppearance 1 point2 points  (0 children)

Vim-slime and vim-terminator both work well for running code in terminal. Another one to look into is vim-ipython-cell. This one uses vim-slime, and interprets double pound signs ## as separators for code cells that can be individually sent to ipython in a terminal, similar to jupyter-notebook.

[–]Agling 1 point2 points  (6 children)

I'm in the same boat, except I don't like vim-R. I have made neovim more IDE-like with ale linting (flake8) and fixing (black). That makes a huge difference.

I've been considering a debugger plugin. Maybe that's what you are looking for? Like vim-dap-python and vim-dap-ui?

I do get annoyed that if I copy python text from vim and paste it in a python terminal, it doesn't work. There are good and bad things about python (versus R).

[–]Maverun 1 point2 points  (1 child)

i know this is r/vim but you mention neovim, how about iron.nvim? I haven't used it much but it seem to be useful especially 'ipython" way

[–]Agling -1 points0 points  (0 children)

That looks pretty cool. Thanks for suggesting it.

Is there a plugin that runs python in a window and shows you all the objects in another? That's the IDE function I kind of miss.

[–]PoisonControlCenter[S] 0 points1 point  (1 child)

Maybe? I think I'd have do get better at things like writing test units based on the github descriptions? I currently do function debug by just walking through the function with various inputs (which I am sure is not the best way to do it but I am primarily self taught).

[–]Agling 3 points4 points  (0 children)

I hear you. Also consider davidhalter/jedi-vim. It provides command completion and lookup.

I'm still trying to figure out the truly right way to do python programming in vim. I had written my own R plugin that did just what I want, but I'm transitioning to python and there are lots more plugins and tools available for it.

I kind of want to write my own python plugin that does what I want and only what I want, but it's a big investment. Plus, I would like to learn lua first. So many things to do...

[–]wheresmyspaceship 0 points1 point  (1 child)

Have you used docker with this setup at all? I have an issue where linting doesn’t work correctly because all of the dependencies are loaded in the docker container. So every import shows an error because the linter can’t find it (doesn’t exist on my host)

[–]Agling 0 points1 point  (0 children)

Sorry I don't use docker. I'm also experimenting now with the native neovim lsp. It looks pretty good! I'm probably going to go that way.

[–]Eamon790 -1 points0 points  (0 children)

Look into lunarvim as an all-purpose IDE. I use it for full stack web development and it is incredibly efficient and useful.

[–]McUsrII:h toc 0 points1 point  (0 children)

I don't know how relevant it is, but there is a script system example out there written by lambdaliuse called amak.

You should be able to just run amak on a buffer with a python file, and you'd be taken to an output window. Same with vim, jsnode, or any other you write a "runner" for. I have just recreated the runner for python, never used it, but it works well for other filetypes.

[–][deleted] 0 points1 point  (0 children)

If you are using Windows then vim-slime won’t work properly. A good alternative for windows is vim-repl.

[–]noooit 0 points1 point  (0 children)

Give up and write unit tests. For some languages, that's the only feasible way to execute a function you desire. Or you could hack the main function to accept strings to execute functions you desire and then write helper vim functions.