Replies: 1 comment 1 reply
-
Thanks, this looks interesting! Instead of 'mini.operators', I think this will have a better fit in the planned 'mini.cycle' (or possibly 'mini.convert') module dedicated to "cycling through alternatives with pre-defined rules". This particular case can be framed as "cycle through different number representations". Your examples will be handy, thanks! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I have a suggestion to make regarding MiniOperators.
Introduction
My most used feature in the plugin is by far the evaluation motion (
g=
), specially when I'm debugging. Instead of reaching topython
or evencalc.exe
, I can dump any math expression with hex and binary numbers and the plugin can give me back the answer. However, when I'm subtracting memory addresses, the decimal representation, given after evaluation, has little to no meaning, forcing me to use another tool to do the decimal to hex conversion.Solution
Create the following motions: (I used my own motion implementation to make the demo video)
gh
motion, like go hex, e.g.255 -> 0xff
;gH
motion, like go HEX, e.g.255 -> 0XFF
;gb
motion, like go bin, e.g.255 -> 0b11111111
;The intended workflow is to after an evaluation motion the user can do an
ghiw
and have the answer converted to hex. In addition,0x
/0X
and0b
/0B
are valid number representations in Lua, so the user can do anotherg=
motion, if they desire.Implementation
Hex
The hex implementation is just a 1 line code, since
string.format
already has hexadecimal formatting builtin.Bin
The bin implementation requires a function to do the conversion, since there is no builtin method.
Why I think this is a good idea?
The hex conversion is trivial and supported by Lua. When working with colors, memory addresses, etc. the hexadecimal representation is the standard way to represent numbers and often they are easier to reason about. And since
g=
force all evaluations to decimal representation, it's good to have a way back to hexadecimal representation.Demo
poc.mp4
Beta Was this translation helpful? Give feedback.
All reactions