Shows a dimmed "ghost" annotation next to hexadecimal (0x…) and octal (0o…)
literals in your code, so you can read their decimal or binary value at a glance
without reaching for a calculator.
const mask = 0xFF // = 255
const perm = 0o755 // = 493
const flags = 0xDEADBEEFn // = 3735928559
The annotation is rendered inline and is never written to your file.
Features
- Inline decimal (or binary) ghost values for
0x/0oliterals. - Handles
BigIntliterals (the trailingn) and values larger than 2^53 exactly, usingBigIntunder the hood. - Updates live as you type and switch editors.
Extension Settings
hexMagic.enabled(defaulttrue): show/hide the ghost annotations.hexMagic.mode("decimal"|"binary", default"decimal"): what to display.
Commands
- Hex Magic: Toggle Ghost Annotations (
hex-magic.toggle) - Hex Magic: Switch Between Decimal and Binary (
hex-magic.cycleMode)
Known Issues
- Only prefixed literals (
0x,0o) are annotated. Bare hex digits are not detected, since they can't be told apart from ordinary numbers.
Development
npm install
npm run compile # or: npm run watch
npm test # runs the conversion/detection tests
Press F5 in VS Code to launch the Extension Development Host and try it on a
file containing 0x/0o literals.