2

In Sublime Text I used small and handy MiniPy plugin. It evaluates each expression in multi-cursor selection and replaces the selection with the result.

For example, I have selected these lines in ST:

1+1
2+1
3+1

When I press <c-s-x> I get:

2
3
4

I use vim-multiple-cursors plugin, but can't see how to make this work.
So my question is how can I evaluate multi-cursor selections in vim, preferably through Python.

Please note that multi-cursor selection doesn't have to be on a separate lines.

vlad
  • 771
  • 2
  • 10
  • 21

1 Answers1

1

I would go with bc, too, but what about a pure Vim command?

:1,3norm c$^R=^R"^M

^R is obtained with <C-v><C-r> and ^M with <C-v><CR>.

As for your question, this will depend on what that plugin does with the "selected" text.

Since Vim doesn't provide non-contiguous selection there's no ready made way to get the content of the multiple "selections" (they are not actual selections) made with that plugin.

You will need that plugin to export the selected text in one way or another and I'm afraid this goes a bit beyond the scope of SO.

I'd suggest you get in touch with the author of that plugin and see if he is able to help you.

That said, you might be interested by Pipe2Eval.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • Thanks, I also think it's good idea to contact the author and hope for answer. I'll do that and report back if there is solution. – vlad Aug 01 '14 at 21:41