The arithmetic plugin uses eval
to evaluate the expression. It would be possible to ignore suffixes of numbers like that if you strip them with a regex replace before. In fact, you can apply the following changes using the ViewPackageResource package:
--- Shipped Packages/Default/arithmetic.py 2019-03-01 16:50:58
+++ Packages/Default/arithmetic.py 2019-08-07 18:17:02
@@ -1,5 +1,6 @@
import sublime_plugin
import math
+import re
def try_eval(str):
@@ -11,6 +12,7 @@
def eval_expr(orig, i, expr):
x = try_eval(orig) or 0
+ expr = re.sub(r"([\d.]+)[^\We]", r"\1", expr)
return eval(expr, {"s": orig, "x": x, "i": i, "math": math}, {})
Note that this isn’t exactly a proper fix because I’m lazy about adjusting orig
, but you’ll understand what to change if you need to.