Sublime Forum

Inc-Dec-Value (ST2 and ST3)

#1

v0.1.12

https://sublime.wbond.net/packages/Inc-Dec-Value
https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value

[size=120]Increase / decrease of numbers (integer and fractional), dates, hex color values, opposite relations or cycled enumerations on the configured value and a bonus - string actions (upper, lower, capitalize)[/size]

Support Multiple Selections

https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/raw/master/inc_dec_number.gif https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/raw/master/inc_dec_hex_color.gif https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/raw/master/inc_dec_opposite.gif https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/raw/master/inc_dec_float.gif https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/raw/master/inc_dec_dates.gif https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/raw/master/inc_dec_strings.gif

Example of the correct values:

- **dates in ISO format `YYYY-MM-DD`**
2011-11-15

The increase in year / month / day is its own, without checking the validity of the resulting date.
For days, the value of loops between 1 and 31, for months - loops between 1 and 12.

- **positive and negative integer numbers**
... -2, -1, 0, 1, 2, ...

- **positive and negative floating-point numbers**
... ... -1.1, -1.19, 0.119, 1.1119, 2.11119, ...

If value is floating-point - increases/decreases applies from last position. for example 1.19 + `alt+up` = 1.20 and 1.11200 + `alt+down` = 1.11199

- **positive and negative numbers and any text after them**
12px, -5em, 100%, 42sometext, (24), [12, -13], {77: -88}, 0.1em, 62.5%/1.5

- **hex colors**
#123 #123456

Pressing the button `alt+up/down` increases/decreases the one character to the left on +1/-1 (regardless of the settings)
If the cursor between the '#' and the hex number in the #123 - the action applies to first character '1'
Pressing the button `super+up/down` increases/decreases the total value of the hex color on +111/-111 or +111111/-111111 (regardless of the settings)

- **opposite relations or cycled enumerations**
true/false, True/False, TRUE/FALSE, left/right
also
truE > false, tRUe > false, FaLsE > true, LeFT > right`

Pressing the key **`super+alt+up/down`** changes the value under the cursor ("true" or "false") to the opposite

**Version 0.1.0** adds the ability to cycle more than two values:

"Jan" > "Feb" > "Mar" > ... > "Dec" > "Jan"

Example of settings see in
[https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/blob/master/inc_dec_value.sublime-settings](https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/blob/master/inc_dec_value.sublime-settings)

- **any string**
string String STRING

Pressing the key `alt+up` makes the first letter in the word in Uppercase (Capitalize) without affecting the remaining characters.
Pressing the key `super+up` makes the word in UPPERCASE.
Pressing the key `alt+down` or `super+down` makes the word in lowercase.

**Important !**
There will be no change of words, which were applied different rules.
For example, the integer "12px" will not be given "px" to upper case, as a rule is applied to modify this value to "13px".

Not supported:

- numbers in the text and after
qwe42asd, text42

- incorrect hex colors
#1 #12 #1234 #12345 #1234567...

- and may be something else that would like to see...
let me know if you find an error
or you will have new ideas

inc_dec_value.sublime-settings https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/blob/master/inc_dec_value.sublime-settings

{ "file": "inc_dec_value.sublime-settings" , "action_inc_min": 1 // default: 1, key: Alt + Up , "action_dec_min": -1 // default: -1, key: Alt + Down , "action_inc_max": 10 // default: 10, key: Super + Up , "action_dec_max": -10 // default: -10, key: Super + Down , "action_inc_all": 100 // default: 10, key: Super + Alt + Up , "action_dec_all": -100 // default: -10, key: Super + Alt + Down , "enums": // write values to the list only in lowercase "yes", "no"] , "true", "false"] , "sun", "mon", "tue", "wed", "thu", "fri", "sat"] ] , "force_use_upper_case_for_hex_color": false , "autosave": false }

Default (Linux).sublime-keymap

[code]
{ “keys”: “alt+up”], “command”: “inc_dec_value”, “args”: { “action”: “inc_min” } },
{ “keys”: “alt+down”], “command”: “inc_dec_value”, “args”: { “action”: “dec_min” } },

    { "keys": "super+up"],       "command": "inc_dec_value", "args": { "action": "inc_max" } },
    { "keys": "super+down"],     "command": "inc_dec_value", "args": { "action": "dec_max" } },

    { "keys": "super+alt+up"],   "command": "inc_dec_value", "args": { "action": "inc_all" } },
    { "keys": "super+alt+down"], "command": "inc_dec_value", "args": { "action": "dec_all" } }

][/code]

0 Likes

Plugin Idea: Number Adder/substracter
ToggleBool for ST2
#2

Interesting concept. It might be cool to make this work for hex colors too so that in a css file i can place the cursor inside a hex color, press a combo and it brightens the color by a certain amount.

0 Likes

#3

Nice, simple but brilliant. One of those things you won’t miss 'til you don’t have.

Thanks for sharing!

0 Likes

#4

I also thought about it, soon will be, comrade

0 Likes

#5

Possibly the most useful plugin (and in such simple code) I’ve ever used.

Awesome :smiley:

0 Likes

#6

[quote=“jbrooksuk”]Possibly the most useful plugin (and in such simple code) I’ve ever used.

Awesome :smiley:[/quote]

for the hex color code will be a little harder :unamused:

0 Likes

#7

Something like this could be helpful as alt+up/down jumps to the beginning/end of the line on os x:

[code]{ “keys”: “alt+up”], “command”: “inc_dec_number”, “args”: { “delta”: 1}, “context”:

  { "key": "preceding_text", "operator": "regex_contains", "operand": "[0-9]+" }
]

}[/code]

I am sure there is a better solution for the context but just for the idea.

0 Likes

#8

UPDATE: added support for hex color

0 Likes

#9

UPDATE: Added ability to change some values ​​(true/false, left/right) on opposite.

0 Likes

#10

UPDATE: Added ability to change some floating-point values.

0 Likes

#11

Inc-Dec-Value: moved to a separate repository github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value

0 Likes

#12

UPDATE: Support dates in ISO format “YYYY-MM-DD”

The increase in year / month / day is its own, without checking the validity of the resulting date.
For days, the value of loops between 1 and 31, for months - loops between 1 and 12.

0 Likes

#13

UPDATE: BONUS - string actions - uppercase/lowercase/capitalize

Pressing the key alt+up makes the first letter in the word in Uppercase (Capitalize) without affecting the remaining characters.
Pressing the key super+up makes the word in UPPERCASE.
Pressing the key alt+down or super+down makes the word in lowercase.

0 Likes

#14

Nice plugin, thanks for sharing.

Could you put it in the Package Control repository to simplify the installation and make it more visible for the users ?

0 Likes

#15

[quote=“bizoo”]Nice plugin, thanks for sharing.

Could you put it in the Package Control repository to simplify the installation and make it more visible for the users ?[/quote]

“PackageControl” - I have not used it yet. It’s really good?
I’m still doing everything manually.

0 Likes

#16

[quote=“rmaksim”]
“PackageControl” - I have not used it yet. It’s really good?
I’m still doing everything manually.[/quote]

Yep, it really make life easier, especially for the automatic update of the plugins.

Simply clone the repository (https://github.com/wbond/package_control_channel), add your plugin and send a pull request.
You could also put a link to github/bitbucket in the Packages\User\Package Control.sublime-settings for plugins not in the central repository (what I’ve done for your plugin and a few others).

0 Likes

#17

+1 for adding this to Package Control (This would really help to discover this nice plugin for potential users - https://forum.sublimetext.com/t/plugin-idea-number-adder-substracter/3211/1)

0 Likes

#18

This plugin is totally awesome. Thank you very very much!

0 Likes

#19

I sent pull request github.com/wbond/package_contro … el/pull/42
Probably have to wait a bit.

0 Likes

#20

UPDATE: v0.1.0

opposite relations or cycled enumerations
true/false, True/False, TRUE/FALSE, left/right
also
** truE > false, tRUe > false, FaLsE > true, LeFT > right`**

Pressing the key **`super+alt+up/down`** changes the value under the cursor ("true" or "false") to the opposite

**Version 0.1.0** adds the ability **to cycle more than two values**:

** “Jan” > “Feb” > “Mar” > … > “Dec” > “Jan”**

Example of settings see in [https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/blob/master/inc_dec_value.sublime-settings](https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/blob/master/inc_dec_value.sublime-settings)

also in v0.1.0 settings added to the menu

Preferences -> Package Settings -> Inc-Dec-Value (Settings and Key Bindings)

0 Likes