Vim Tips Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Vim Tips Wiki
1,649
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
Editing
Calculator and code evaluation using Perl
Back to page
Edit
Edit source
View history
Talk (0)
Edit Page
Calculator and code evaluation using Perl
We recommend that you
log in
before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your
Watchlist
.
Creating an account
is quick and free.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
{{review}} {{TipImported |id=1359 |previous=1356 |next=1361 |created=October 17, 2006 |complexity=basic |author=Michael Hooreman |version=n/a |rating=12/5 |category1= |category2= }} This is a Perl variation of [[VimTip1235]]. You can calculate with Perl inside Vim, and do more by adding the following to your vimrc: <pre> :command! -nargs=+ Evaluate :perl VIM::Msg(eval{<args>}) </pre> This prints the last statement value of the provided code as argument, so you can do more than a calculation. Examples: <pre> :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 </pre> ==Comments== An alternative is [[VimTip1349]]. Does not need Python nor Perl. ----
Summary:
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Navigation
(
view source
)
Template:Review
(
view source
)
Template:TipImported
(
view source
)
Follow on IG
TikTok
Join Fan Lab