2

When using vim (or any other text editor) for python scripts, is there a way to run a section of your script alone?

Matlab has a feature where beginning a line with %% splits the lines of code that follow into a section of its own, that can be run independently. Is there a way of achieving this without having to use iPython? Even if the solution is a bit hacky, it would be an improvement over what I currently am doing, which is commenting out blocks that I don't want to run.

Palestrina
  • 37
  • 3
  • 2
    here you can find a detailed answer https://stackoverflow.com/questions/40289706/execute-selection-from-script-in-vim/40290101 – Giovanni Frison Feb 18 '21 at 15:52
  • Visit https://stackoverflow.com/questions/23550853/how-to-run-a-section-of-code-in-python-similar-to-matlab – Shima K Feb 18 '21 at 15:53

1 Answers1

1

A generic solution would be vim-slime: https://github.com/jpalardy/vim-slime

SLIME is an Emacs plugin to turn Emacs into a Lisp IDE. You can type text in a file, send it to a live REPL, and avoid having to reload all your code every time you make a change.

Vim-slime is a humble attempt at getting some of these features into Vim. It works with any REPL and isn't tied to Lisp.

okket
  • 2,031
  • 3
  • 11
  • 14