HexBinDec
This package provides ability to inplace change the base of numbers in SublimeText 3 Editor.
Usage
-
Move the cursor over a number or select one or more numbers.
-
Press one of the following key combinations to convert the numbers (replace
ctrl
withsuper
for MacOS):- ctrl+k, b, d binary to decimal
- ctrl+k, b, h binary to hexadecimal
- ctrl+k, d, b decimal to binary
- ctrl+k, d, e decimal to exponential
- ctrl+k, d, h decimal to hexadecimal
- ctrl+k, e, d exponential to decimal
- ctrl+k, h, b hexadecimal to binary
- ctrl+k, h, d hexadecimal to decimal
- ctrl+k, u, f, d unsigned fixed to decimal
- ctrl+k, s, f, d signed fixed to decimal
- ctrl+k, s, b, d signed binary to decimal
- ctrl+k, s, b, h signed binary to hexadecimal
The commands are available in
- command pallet under
Convert Number: ...
- main menu -> edit -> Convert Numbers
- context menu -> Convert Numbers
Setup
You can setup patterns to identify binary, fixed point, decimal, and hexadecimal numbers for each syntax just by adding the following settings to the syntax specific settings file <scope>.sublime-settings
.
// ...
// Define the format of binary numbers for the Hex-Bin-System plugin
// Binaries look like 'B101110'
"convert_src_bin": "'B([01]+)'",
"convert_dst_bin": "'B{0:b}'",
// Define the format of hexadecimal numbers for the Hex-Bin-System plugin
// Hexadecimals look like 'H1AF23'
"convert_src_hex": "'H([0-9A-F]+)'",
"convert_dst_hex": "'H{0:X}'",
// Define the format of exponential numbers for the Hex-Bin-System plugin
// The pattern must match the base as group 1 and exponent as group 2.
// Exponential numbers look like 3.14EX-4
"convert_src_exp": "\\b([1-9]\\.\\d+)EX([-+]?\\d+)\\b",
"convert_dst_exp": "EX",
// ...
Inspired by
Hex-Bin-System by ALLZ and HexBinDec by deathaxe