Vim Tips Wiki

Calculator and code evaluation using Perl

1,613pages on
this wiki
Revision as of 13:09, November 8, 2011 by Emprego.curitiba (Talk | contribs)

Tip 1359 Printable Monobook Previous Next

created October 17, 2006 · complexity basic · author Michael Hooreman · version n/a

This is a Perl variation of VimTip1235.

You can calculate with Perl inside Vim, and do more by adding the following to your vimrc:

:command! -nargs=+ Evaluate :perl VIM::Msg(eval{<args>})

This prints the last statement value of the provided code as argument, so you can do more than a calculation.


:Evaluate 1+2
 > 3

:Evaluate sin(0)
 > 0

:Evaluate $a=sin(0);$a==sin(0)?"equal":"not equal"
 > equal

:Evaluate @a=(0..10); join "", map{$_%2?"-":$_}@a;
 > 0-2-4-6-8-10


An alternative is VimTip1349.

Does not need Python nor Perl.

Sex Shop Sex Shop Sex Shop Sex Shop Sex Shop Dicas de Sexo Lingerie Calcinhas Uniformes Profissionais Uniformes

Around Wikia's network

Random Wiki