I’ve been using Sublime Text as my main text editor since August of 2014. I know it pretty well, but occassionally I still learn something new and useful.
Today I learned about the Arithmetic command from a video by OdatNurd.
Summary of what I learned
Variables
The following variables are supported:
| Variable | What it does |
|---|---|
s | The literal selected text |
i | The selected text interpreted as a number (0, if interpretation fails) |
i | The index of each selection (0-indexed) |
Converstions
hex(x) // to hex
int(x) // to decimal
bin(x) // to binary
format() is supported
format(x, ',') // add comma separators to number, 1234 -> 1,234
format(x, '^80') // center selected text in 80-character column
math package is supported
math.ceil(x)
math.floor(x)
TIP: Update numbers of an ordered list
This is particularly useful; I do this all the time!
- Select each number, split selection to lines
- Open
Command Palette...>Arithmetic - Enter:
i+1 - Done!