4 ms·
I don't know of a plugin, but you can sorta do something kinda like the thing ish if you squint and cross your fingers... You can perform actual in-place calcu
by JNRowe 6y ago
I don't know of a plugin, but you can sorta do something kinda like the thing ish if you squint and cross your fingers...
You can perform actual in-place calculations by using the expression register. So for example:
= 2 + 2
<insert mode cursor here>
Then something like `<C-r>=eval(getline('1h')[2:])` will end up with:
= 2 + 2
4
If you regularly did so writing a more robust mapping would probably useful.
And using regular :global you could perform similar operations across a file with `:g/^= / <expression replacement>`
I think the real solution would be just to use evil-mode in emacs when you wish to use things like literate-calc-mode. I do that for org-mode because it is just so much more powerful than the basic vim plugin for org-mode files.
> Is it something very difficult in vim?
Since 8.2 was released you can use popupwin¹ to emulate something similar. I'd probably give it a go if you wrote it :P
It is a real shame you can't use a funcref(or even multiple characters) for conceal replacement, or you could simply add a conceal² for => to show the result. Such functionality would also be nice for inlining computed types in various languages too.
¹ https://vimhelp.org/popup.txt.html https://vimhelp.org/popup.txt.html
² https://vimhelp.org/syntax.txt.html#conceal https://vimhelp.org/syntax.txt.html#conceal