Sequence ToolThe Sequence Tool extension for Visual Studio Code allows you to easily insert custom sequences with a live preview. FeaturesInsert Custom Sequence With Multi-cursors -
|
Field | Definition |
---|---|
fillChar | Character used to pad to the given width. The alignment must be specified, excpet for fillChar=0 . |
align | Use > for right-align and < for left-align within the available space. |
.prec | The number of digits to be displayed after the decimal point for the f spec. |
spec | Specifies how the value should be displayed (refer to details below). |
init | Initial value of sequence, defaults to 0 (see details below). |
expr | The function (p, i) => expr generates the next value of the sequence. (see details below) |
Spec
The spec field allows you to customize how the sequence values are displayed.
Here are some format specifiers:
Field | Definition |
---|---|
b | Binary number. |
o | Octal number. |
d | Decimal integer number. |
h,x,H,X | Hexadecimal number, use H or X for uppercase digits. |
f | Decimal fractional numbers. |
c | Converts to single Unicode character. |
b\d+ | Convert to other bases, can be 2 to 36 (For example: b36 for base 36). |
Init
Type | Definition |
---|---|
Number | Number literal, can be fractional. |
English Letter | Generates the spreadsheet column name sequence. |
JavaScript Expression | Any valid javascript expressions. |
Expr
You can customize how the next value of the sequence is generated using the expr field. The function (p, i) => expr allows you to define the logic for generating the next value.
For example, to generate a sequence with a step size of 2, you can use (p, i) => p + 2.
Parameter | Definition |
---|---|
p | The previous value of the sequence, initalized by init. |
i | Zero-based index of the sequence. |
Extension Settings
This extension contributes the following settings:
sequence-tool.customCommands
: Store your frequently used commands here. These commands will appear in thesequence-tool.useCommand
command and can be invoked through keybindings.
Example
Example Settings:
Item | Value |
---|---|
ascii uppercase | c,65,i<26?p+1:'' |
day of week | ,,['Sun','Mon','Tue','Wed','Thu','Fri','Sat'][i%7] |
factorial | ,1,p*(i+1) |
Fibonacci | d,,(((1+Math.sqrt(5))/2)**i-((1-Math.sqrt(5))/2)**i)/Math.sqrt(5) |
Catalan | ,1,(4-6/(i+2))*p |
Look and say | ,1,`${p}`.replace(/(.)\1*/g, m=>`${m.length}${m.substring(0, 1)}`) |
Keybindings
You can invoke commands through custom keybindings. Access the keybindings JSON by selecting Preferences: Open Keyboard Shortcuts (JSON).
Example keybindings for the factorial command and the preconfigured Catalan number command:
// Execute a command (factorial) on keypress
{
"key": "ctrl+alt+,",
"command": "sequence-tool.insertSequence",
"args": { "command": ",1,p*(i+1)" }
},
// Pick a preconfigured command (Catalan numbers) on keypress
{
"key": "ctrl+alt+.",
"command": "sequence-tool.useCommand",
"args": { "name": "Catalan" }
}
Release Notes
See CHANGELOG.md.
Special Thanks!
- Special thanks to tomoki1207/vscode-input-sequence for the live preview functionality.