mega-increment README
Mega-increment extension is intended to ease parallel independent incrementations and decrementations in various strings. It can be used in writing code for lists, enums, arrays, tests, html and xml tags, csv files, data base examples and tests, date-time iterations, hexadecimal and binary register allocations and many other uses.
Basic functionality is available in the editor tabs and advanced options are implemented in a separate GUI tab.
Editor supports only single line mode (and cursor has to stay on line from which commands are called).
GUI supports multiline , changing line, interactivity , exports and other advanced options.
Editor:
GUI Advanced Increment:
There are also example videos on YouTube for editor and GUI Advanced Increment.
If you have found a bug or other issue or you have feature request please write here: https://github.com/vladanan/mega-increment/issues
If you want to donate and support further extension development
you can do it via PayPal
or you can
Contents
Shortcuts
How it works
Example with numbers
Date, time
Units and decimal point
Simple, random, crypto
Hex and binary
Overlapping selections and deleting all selections
Enums and lists
GUI for Advanced Increment
Continuous and ranged enum variants
Public API
Settings
FAQ
Known Issues
Licence
Shortcuts
There are four simple commands which are used in editor:
- when some part of line is selected user can add it for incrementation (and then select type and stepping)
- start incrementing by adding lines below the line where the cursor is
- delete all selected parts for incrementation after work is done to prevent overlapping selections and misplacement of new lines
- start Advanced GUI mode
All commands are available in VSCode standard Command Palette (Linux/Windows: Ctrl+Shift+P / F1, Mac: ⇧⌘P / F1).
Tip: By typing 'mega' in Command Palette you get all of them quickly.
Command Palette name |
Default shortcut* |
Mac shortcut* |
Shortcuts other devs use |
Mega: Add selection for increment |
Ctrl + Alt + 8 |
⌥ ⌘ 8 |
Ctrl+Shift+8, Ctrl+Alt+J, Ctrl+Shift+Q |
Mega: Do increment |
Ctrl + Alt + U |
⌥ ⌘ U |
Ctrl+Shift+Insert, Ctrl+Shift+U |
Mega: Clear all selections |
Ctrl + Alt + 0 |
⇧ ⌘ 0 |
Ctrl+Shift+Delete, Ctrl+Alt+X |
Mega: Advanced increment |
Ctrl + Alt + 9 |
⌥ ⌘ 9 |
Ctrl+Shift+9, Ctrl+Shift+4, Ctrl+Alt+7 |
* Shortcuts can be changed in VSCode settings.
* On Macs ⌥ ⌘ 0 is by default used for Toggle editor layout.
* On Windows 10 with default shortcut for add selection Ctrl+Alt+8 an apostrophe is written and selected text is deleted. After several shortcut combinations tested Ctrl+Alt+J works well.
Back to Contents
How it works
In the editor select part of text on line.
Then issue add command (Ctrl+Alt+8 / ⌥ ⌘ 8) to add it for incrementing.
Tip: You can also right click on selected text and choose Mega: Add selection for increment.
Choose the type of text which indicates to the incrementer how to treat selected text (available type options depend on what is selected).
Choose stepping for incrementation, default steppiing is set to 1:
After entering your desired stepping and hitting Enter you will get notification about new selection added and also Status bar info about it:
You can also click on Status info bar and get more information about current selections.
In extension settings one can disable all notifications except for overlapping selection(s).
Issue command for increment (Ctrl+Alt+U / ⌥ ⌘ U) 9 times and then below the active line new lines will appear with selected part incremented.
Tip: You can also click on Status bar Increments button.
If work is finished and you want to try new increment then delete current selection(s) and increments with Ctrl+Alt+0 / ⇧ ⌘ 0.
Tip: You can also click on Status bar Clear all selections button: .
If you didn't finish adding selections and accidentaly hit increment you need to delete all and start over.
If you don't delete previous selections and increments and delete some of lines below or add new selections chances are that the result will not be as expected.
That's it!
Let's see that in motion:
Back to Contents
Example with numbers
If we want this li :
<li style="background-color: rgb(200, 69, 98); width: 120px;">Increment test</li>
- Increment test
to be repeatedly changed in a way to gradually decrease red color and at the same time to increase width of element.
For that we would:
select 200 , add it for increment by Ctrl+Alt+8, choose number type, input stepping -20
then select 120 , add it to increment, choose number type, input stepping 20
if we then increment that for eight times by Ctrl+Alt+U we should get this:
<li style="background-color: rgb(200, 69, 98); width: 120px;">Increment test</li>
<li style="background-color: rgb(180, 69, 98); width: 140px;">Increment test</li>
<li style="background-color: rgb(160, 69, 98); width: 160px;">Increment test</li>
<li style="background-color: rgb(140, 69, 98); width: 180px;">Increment test</li>
<li style="background-color: rgb(120, 69, 98); width: 200px;">Increment test</li>
<li style="background-color: rgb(100, 69, 98); width: 220px;">Increment test</li>
<li style="background-color: rgb(80, 69, 98); width: 240px;">Increment test</li>
<li style="background-color: rgb(60, 69, 98); width: 260px;">Increment test</li>
<li style="background-color: rgb(40, 69, 98); width: 280px;">Increment test</li>
Lets see that in real:
Remember:
- When you want to delete chosen selection(s) and start over again then issue clear command (Ctrl+Alt+0) or click on Status bar Clear all selections button .
- If you want to try the same thing in Advanced GUI issue advanced increment command (Ctrl+Alt+9) or right click on line and then click Mega: Advanced increment.
If you use decimal stepping on integer numbers i.e. inputting stepping of 0.333333 they will not turn in to floating point but instead they will be incremented every third time. If you input stepping of 0.25 increment will occur every fourth time, for 0.2 fifth and so on. This fractional stepping is available also for simple, date, time and enums.
Numbers with floating point are recognized by decimal point, so if you want 5 to be incremented by 0.2 you should write it as 5.0.
Back to Contents
Date, time
- Lets say that we need alarms fetched from translation JSON but from every second day and ten minutes earlier. We start with this:
const alarms: Alarm[] = [
{ day: t('alarm.items.day.2024-01-15'), time: t('alarm.items.time.13:00:00') },
];
- Select day part
2024-01-15 , add, choose YYYY-MM-DD type, input stepping 2
- Select time part
13:00:00 , add, choose hh:mm:ss type, input stepping -600 (10min = 600sec)
- Hit increment several times and we get this:
const alarms: Alarm[] = [
{ day: t('alarm.items.day.2024-01-15'), time: t('alarm.items.time.13:00:00') },
{ day: t('alarm.items.day.2024-01-17'), time: t('alarm.items.time.12:50:00') },
{ day: t('alarm.items.day.2024-01-19'), time: t('alarm.items.time.12:40:00') },
{ day: t('alarm.items.day.2024-01-21'), time: t('alarm.items.time.12:30:00') },
{ day: t('alarm.items.day.2024-01-23'), time: t('alarm.items.time.12:20:00') },
{ day: t('alarm.items.day.2024-01-25'), time: t('alarm.items.time.12:10:00') },
{ day: t('alarm.items.day.2024-01-27'), time: t('alarm.items.time.12:00:00') },
{ day: t('alarm.items.day.2024-01-29'), time: t('alarm.items.time.11:50:00') },
{ day: t('alarm.items.day.2024-01-31'), time: t('alarm.items.time.11:40:00') },
{ day: t('alarm.items.day.2024-02-02'), time: t('alarm.items.time.11:30:00') },
];
- For now
time formats are without milliseconds.
- YYYY-MM-DD: date part from ISO full date string,
YYYY-MM and MM-DD are also available.
- hh:mm:ss: time part without millisecond from ISO full date string,
hh:mm and mm:ss are also available.
Tip: Date: If you want to increase only months then don't increase days by 30 because not all months have 30 days. Better select only month and increment by appropriate stepping.
Tip: To increase minutes and hours by seconds then multiply minutes with 60 and hours by 3600.
- If you use decimal stepping on date and time i.e. inputting stepping of 0.333333 they will be incremented every third time. If you input stepping of 0.25 increment will occur every fourth time, for 0.2 fifth and so on. This
fractional stepping is available also for types: simple, integer numbers and enums.
- Some other date and time formats might be implemented in extension. If you need some of them please submit feature request at: https://github.com/vladanan/mega-increment/issues
Back to Contents
Units and decimal point
- What if we need shipping table with increasing weights by 12.6kg and decreasing price by $0.6 for bulk transport?
<table>
<tr><td>Below 12.5kg</td><td>$2.00/kg</td></tr>
<tr><td>From 12.5kg to 25kg</td><td>$1.94/kg</td></tr>
<tr><td>Above 88kg</td><td>$1.50/kg</td></tr>
</table>
- We increment
12.5 with stepping 12.6, 25 by stepping 12.6 and 1.94 by stepping -0.06 and we get:
<tr><td>From 12.5kg to 25kg</td><td>$1.94/kg</td></tr>
<tr><td>From 25.1kg to 37.6kg</td><td>$1.88/kg</td></tr>
<tr><td>From 37.7kg to 50.2kg</td><td>$1.82/kg</td></tr>
<tr><td>From 50.3kg to 62.8kg</td><td>$1.76/kg</td></tr>
<tr><td>From 62.9kg to 75.4kg</td><td>$1.70/kg</td></tr>
<tr><td>From 75.5kg to 88kg</td><td>$1.64/kg</td></tr>
Below 12.5kg | $2.00/kg |
From 12.5kg to 25kg | $1.94/kg |
From 25.1kg to 37.6kg | $1.88/kg |
From 37.7kg to 50.2kg | $1.82/kg |
From 50.3kg to 62.8kg | $1.76/kg |
From 62.9kg to 75.4kg | $1.70/kg |
From 75.5kg to 88kg | $1.64/kg |
Above 88kg | $1.50/kg |
Back to Contents
Simple, random, crypto
- Maybe you need to increase individual characters, get random or safe crypto values?
const autoTokens: Token[] = [
{ subject: 'abcd', key: 'stupid_admin', crypto_pass: '12345678901234567890'},
];
- For
abcd choose type simple and stepping 1, for stupid_admin choose type random, for '12345678901234567890' choose type crypto. No need for stepping for random and crypto. If we increment this several times we get something like this:
const autoTokens: Token[] = [
{ subject: 'abcd', key: 'stupid_admin', crypto_pass:'12345678901234567890'},
{ subject: 'bcde', key: 'Iz_WnRfty+aC', crypto_pass:'7875368010268182393'},
{ subject: 'cdef', key: '<!GQ)>aR,F.y', crypto_pass:'4163091229532004722'},
{ subject: 'defg', key: '/iz)iB'nJ2@z', crypto_pass:'4212026588723949856'},
{ subject: 'efgh', key: 'Sx]dz-/6f#'a', crypto_pass:'16251594422145675523'},
{ subject: 'fghi', key: '0=nlwnh#x*)m', crypto_pass:'15652820121626408202'},
{ subject: 'ghij', key: ',fI7)nvBNi2D', crypto_pass:'16875909354991980776'},
{ subject: 'hijk', key: 'siCfWN:j^y\;', crypto_pass:'10664457782404241384'},
{ subject: 'ijkl', key: 'I%~VHGDW4Yo$', crypto_pass:'10809599484200095278'},
{ subject: 'jklm', key: 'p(yb!~KfhtN^', crypto_pass:'13851775674538229405'},
{ subject: 'klmn', key: 'S\PVVc4B{J?h', crypto_pass:'17372568455703339876'},
{ subject: 'lmno', key: 'mt7dZ\zZ=}t?', crypto_pass:'4400204851546143125'},
{ subject: 'mnop', key: 'tceHL8!+&zeK', crypto_pass:'11185827497145895769'},
];
- simple: any string whom individual characters will be incremented by ASCII order i.e.: abcd, bcde, cdef, defg... It supports
fractional stepping .
- crypto: integer which will be followed by cryptographically safe array of numbers. Any integer can be selected but result numbers will be in 8/16/32/64bit format depending (not precisely) on number of digits in selected number.
- random: any string which will be followed by random printable ASCII characters, not cryptographically safe format.
- For
crypto and random stepping is irrelevant.
Back to Contents
Hex and binary
- Maybe we need to increment hexadecimal and binary numbers in ASCII?
<h2>Nice hex stars ✻ converted to lots of binary digits 0010011100111011</h2>
- Increase hex part
273B not &#x by type hex and stepping 1, then 0010011100111011 by type binary and also stepping 1. And we get:
<h2>Nice hex stars ✻ converted to lots of binary digits 0010011100111011</h2>
<h2>Nice hex stars ✼ converted to lots of binary digits 0010011100111100</h2>
<h2>Nice hex stars ✽ converted to lots of binary digits 0010011100111101</h2>
<h2>Nice hex stars ✾ converted to lots of binary digits 0010011100111110</h2>
<h2>Nice hex stars ✿ converted to lots of binary digits 0010011100111111</h2>
<h2>Nice hex stars ❀ converted to lots of binary digits 0010011101000000</h2>
<h2>Nice hex stars ❁ converted to lots of binary digits 0010011101000001</h2>
<h2>Nice hex stars ❂ converted to lots of binary digits 0010011101000010</h2>
<h2>Nice hex stars ❃ converted to lots of binary digits 0010011101000011</h2>
<h2>Nice hex stars ❄ converted to lots of binary digits 0010011101000100</h2>
<h2>Nice hex stars ❅ converted to lots of binary digits 0010011101000101</h2>
<h2>Nice hex stars ❆ converted to lots of binary digits 0010011101000110</h2>
Nice hex stars ✻ converted to lots of binary digits 0010011100111011
Nice hex stars ✼ converted to lots of binary digits 0010011100111100
Nice hex stars ✽ converted to lots of binary digits 0010011100111101
Nice hex stars ✾ converted to lots of binary digits 0010011100111110
Nice hex stars ✿ converted to lots of binary digits 0010011100111111
Nice hex stars ❀ converted to lots of binary digits 0010011101000000
Nice hex stars ❁ converted to lots of binary digits 0010011101000001
Nice hex stars ❂ converted to lots of binary digits 0010011101000010
Nice hex stars ❃ converted to lots of binary digits 0010011101000011
Nice hex stars ❄ converted to lots of binary digits 0010011101000100
Nice hex stars ❅ converted to lots of binary digits 0010011101000101
Nice hex stars ❆ converted to lots of binary digits 0010011101000110
- Hex is case insensitive and produces lowercase letters.
- Hex & binary are not tested with negative numbers yet, take care of results for signed values.
Back to Contents
Overlapping selections and deleting all selections
- If we make selection which overlaps with other then the extension will delete existing selection(s) and ignore new one. In previous example
<h2>Nice hex stars ✻ converted to lots of binary digits 0010011100111011</h2>
- that can be done by first selecting and adding
Nice and than e hex . Or selecting Nice and stars and then e hex s . In first case Nice would be deleted and in second case Nice and stars would be deleted.
- When you want to delete all chosen selections at once and start over again then issue clear command (Ctrl+Alt+0).
Back to Contents
Enums and lists
- Enums and lists work as JSON arrays which are predefined in extension settings.
- You go to VSCode Settings (Ctrl + ,)(Mac: ⌘ ,) and then find
Mega Increment section or just type 'mega' in search field and you get to Mega Increment settings quickly.
- Once there find
Mega-increment: Key Value Pairs , click Add Item , in Key field write title for your enum/list, in Value field write enum/list in JSON array format, for example for months:
- Key: months
- Value: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
- Click
OK
- You have your first enum and you can make lots of them. Also you can edit or delete them.
- Depending on OS especially on some Linux systems VSCode might have to be restarted for some settings to take effect.
- Now with enum set up we can use it. We can step through enums in stepping just like other types. Se we will select every other month by selecting
January , choose type enum , stepping 2 and then increment 5 times:
switch (year.selectedMonth) {
case 'January': console.log("Write here something about this season."); break;
case 'March': console.log("Write here something about this season."); break;
case 'May': console.log("Write here something about this season."); break;
case 'July': console.log("Write here something about this season."); break;
case 'September': console.log("Write here something about this season."); break;
case 'November': console.log("Write here something about this season."); break;
default: break;
}
- We do not have to start from the beginning of enum and we also can use negative stepping i.e. we can move through the enum backwards. So in the next example we start from
November and move backwards 3 steps with stepping -3:
switch (year.selectedMonth) {
case 'November': console.log("Write here anything about this season."); break;
case 'August': console.log("Write here anything about this season."); break;
case 'May': console.log("Write here anything about this season."); break;
case 'February': console.log("Write here anything about this season."); break;
default: break;
}
- There are more interesting and powerful tricks we can do with enums. So lets create two more enums to see how it works. In Mega Increment settings we create two enums:
- Key: colors, Value: ["blue","salmon","cyan","gray","green"]
- Key: saturation, Value: ["light","","dark"]
- We start with this:
<p style="color: darkblue" >This text will be interesting to see.</p>
- Then we select
dark , add with type enum, stepping 1. Next we select blue , add with type enum, stepping 0.333333, and then increment 15 times. We get this:
<p style="color: lightblue" >This text will be interesting to see.</p>
<p style="color: blue" >This text will be interesting to see.</p>
<p style="color: darkblue" >This text will be interesting to see.</p>
<p style="color: lightsalmon" >This text will be interesting to see.</p>
<p style="color: salmon" >This text will be interesting to see.</p>
<p style="color: darksalmon" >This text will be interesting to see.</p>
<p style="color: lightcyan" >This text will be interesting to see.</p>
<p style="color: cyan" >This text will be interesting to see.</p>
<p style="color: darkcyan" >This text will be interesting to see.</p>
<p style="color: lightgrey" >This text will be interesting to see.</p>
<p style="color: grey" >This text will be interesting to see.</p>
<p style="color: darkgrey" >This text will be interesting to see.</p>
<p style="color: lightgreen" >This text will be interesting to see.</p>
<p style="color: green" >This text will be interesting to see.</p>
<p style="color: darkgreen" >This text will be interesting to see.</p>
- So what happened with color attribute? Enum ["light", "", "dark"] went normally with stepping 1, but enum ["blue", "salmon", "cyan","gray", "green"] because of stepping 0.333333 changed
only once every third time so for each color we get three variants of different saturation (light, normal, dark). This kind of fractional stepping we can also do with integer numbers, date, time and simple. Try it yourself.
Here are few already prepared enums which you may find useful during work and insert them in Mega Increment settings.
- Key: week days, Value: ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
- Key: short days, Value: ["sun","mon","tue","wen","thu","fri","sat"]
- Key: colors, Value: ["red","green","blue","cyan","magenta","yellow","black"]
- Key: roman numerals, Value: ["I","II","III","IV","V","VI","VII","VIII","IX","X"]
- Key: numbers, Value: ["one","two","three","four","five","six","seven","eight","nine","zero"]
There are two variants of enums but since they can be interchangeably used only in Advanced Increment GUI they will be covered later.
Back to Contents
GUI for Advanced Increment
Graphical user interface for Advanced increments provides user with interactive incrementing, detailed picture of selections, enums, result, changing line text with active settings, multi line strings, direct insert of enums in line text, retrieving line text, changing variant of enums, exporting results, exporting API calls and more to come.
Lets se how it looks on previous example with colors.
- Advanced increment tab
Line text section:
- Number of times the line text is incremented
- Line text is automatically retrieved from editor, select some part of text and then click on type button below according to which you want increment to be made
- Use Alt+8 to get focus on line text
More information about Alt+8 and other web accesskeys in: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey
- Line text can be retrieved back if changed or lost
Types section, buttons enable choosing type for selected text, available button types depend on what kind of text is selected:
- Basic forms of incrementing: simple which treats selected text as sweet of individual characters and number for integers and floating point numbers
- JS group for enums/lists, date and time
- C group for hex, binary, random and crypto types
Enums section:
- Table of available enums in mega increment settings, from this table new enums can be inserted in line text
- Button for inserting enums from table (alongside those maybe already present in text line)
Selections section:
- Table with details about selections
- Buttons for:
- deleting all selections (shortcut Alt+0)
- export of active setup as curl API call (Be careful when using
' and " in curl API calls from (Linux/Mac) shell(s). Because of shell performing string concatenation on the command line and JSON format which depends on "" you probably must: escape each ' with '\'' for shell concatenation, escape each " with \" for JSON parsing. In some programming languages practical implementation for escaping like this might require additional escaping of backslash \ character so it might look as this: '\\'' and \\" .)
Result section:
- Area for interactive display of incrementing result
- Buttons for exporting the result to:
- editor (when back in editor go to the end of line and hit Ctrl+Alt+U to retrieve result from GIU)
- clipboard and
- JSON array.
Let's see that in motion:
Back to Contents
Continuous and ranged enum variants
continuous: treats enum list as continuous i.e. infinite and increments items in linear fashion. When incrementation reaches the end of list it goes further like there is new list attached. If we increment enum with simple numbers ["one","two","three","four","five","six","seven","eight","nine","ten"] starting from one and with stepping 3 we will have: one , four , seven , ten and then: three (lite thirteen), six (like sixteen), nine (like nineteen) etc. etc.
ranged: enum list is contained in its range so increments beyond list length are trimmed. This variant makes sense if you start from the beginning or middle of the enum but if you start from near the end it makes less sense:
- Let's say we start from
six with stepping 3 in numbers. After 2 increments it goes out of the enum range because six + 3 = nine and +3 = twelve :
- but we can't go to
twelve or two because we selected ranged variant so two and the rest will be trimmed
- and we also can't go to
one because it is not the starting position and it also doesn't fit for decrement: six -3 = three and -3 = zero , so one is not solution.
- So in this case and only 2 items from enum will be repeated constantly in result:
six and nine .
- Therefore, ranged is very specific and you must clearly understand how it behaves in order to use it correctly in relation to continuous. Best is to first test result with your expectations.
Back to Contents
Public API
This project includes public API with same functions as extension. You can see the MACf API Documentation at GitHub.
Back to Contents
Settings
For Mega Increment settings you go to VSCode Settings and then find Mega Increment section or just type 'mega' in search field and you get to those settings quickly.
- Depending od OS especially on some Linux systems VSCode might have to be restarted for some settings to take effect.
This extension contributes the following settings in VSCode:
Mega-increment: Default Stepping : Choose default stepping for editor and GUI.
Mega-increment: Default Enum Variant : Choose default incrementation variant for enums.
- continuous: Treats enum list as continuous i.e. infinite and increments items in linear fashion.
- ranged: Enum list is contained in its range so increments beyond list length are trimmed.
Mega-increment: Disable Notifications : Disable all notifications except for overlapping selection(s).
Mega-increment: Key Value Pairs : Create custom key value pair lists for frequently used enums and lists.
Back to Contents
FAQ
Why would this extension be needed if those same things can be programmed at need with loops etc.?
I developed this extension from my personal need so I can vouch for the following reasons:
- You will lose more time to program any of the custom increments than to produce it via extension.
- Yes, programmed snippets can be reprogrammed and extended but that is also true for snippets from extension, except for highly customized and isolated cases.
- Snippet from extension is easier to read and maintain.
- Snippet from extension is faster to produce and use for testing:
- If code works well it can be later optimized
- If you find out that you don't need such code then at least you didn't spend a lot of time developing custom code.
Since I offer a public API outside of extension anyone from any app can use extension power instead of writing custom code for most standard increments and decrements.
Can this be done using AI? Yes but it would usually last longer and with uncertain results.
Why GUI sections are divided and named Basic, JS, C?
Just for fun.
Back to Contents
Known Issues
Windows 10:
- With default shortcut for add selection Ctrl+Alt+8 an apostrophe is written and selected text is deleted. The same can happen wiht Ctrl+Alt+9 or 0. After several shortcut combinations tested Ctrl+Alt+J works well.
- When items are selected with
Enter in menu in editor sometimes Enter is written in editor itself so selection iz overwritten and new line is inserted. After Ctrl+Z Undo all works well.
Mac:
- After making selections and change window (i.e. open Safari) and them perform increments position of incremented lines is moved from where they should be. Sometimes this can happen even without changing application window. It appears that for some reason MacOS is messing with cursor position for Visual Studio Code.
Back to Contents
Licence
Copyright (C) Vladan Anđelković. All rights reserved.
| |