ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Inc-Dec-Value

by Razumenko Maksim ST2/ST3

increase / decrease of numbers, dates, hex color values, etc.

Details

  • 2016.06.28.13.08.24
  • github.​com
  • github.​com
  • 1 year ago
  • 1 hour ago
  • 6 years ago

Installs

  • Total 36K
  • Win 21K
  • OS X 10K
  • Linux 5K
Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5
Windows 14 21 25 25 17 15 25 22 33 10 27 19 17 18 21 23 29 20 23 12 15 14 17 12 19 25 18 14 20 23 37 29 42 23 39 24 41 25 27 40 22 19 24 20 16 16
OS X 4 0 3 4 4 3 4 1 3 2 6 6 1 3 5 6 4 5 1 8 4 4 3 4 5 3 1 3 6 11 6 4 9 2 8 9 5 7 5 3 0 4 4 4 3 4
Linux 5 2 2 2 2 3 6 4 1 6 3 5 5 1 1 4 3 4 4 4 5 3 5 3 3 7 6 7 2 4 4 4 4 4 3 3 8 5 5 0 6 2 5 1 5 5

Readme

Source
raw.​githubusercontent.​com

Inc-Dec-Value

v0.1.21 - #40 enums: fixed for values with few “-” and with “(” “)”

v0.1.20 - #41 Insert cutting preceding characters

v0.1.19 - #30 cursor duplicates…

v0.1.18 - #33 added settings for RGB instead RGBA

v0.1.17 - #34 space after comma in rgba

v0.1.16 - #32 convert from rgba() to short notation if its possible

v0.1.15 - convert from rgba(x,x,x,1): remove /* alpha: 1 */ if alpha == 1

v0.1.14 - #37 New Feature & Bug Fixes

v0.1.13 - #35 Cycle through enum with Java capitalization

v0.1.12 - #27 Ability to autosave after incrementing

v0.1.11 - #31 ST3: Getting TypeError in console when using the number inc/dec functions

v0.1.10 - #31 ST3: Getting TypeError in console when using the number inc/dec functions

v0.1.9 - Fixed apply_integer (x -> -x when cursor before x)

v0.1.8 - #29 Fix apply_hex_color exception

v0.1.7 - #19 Swapping the color notation in CSS

v0.1.6 - #20 (upper, lower, capitalize) works on non-ascii strings

v0.1.5 - #15 Don't place action in undo history when nothing happens

v0.1.4 - #14 Saving the position of the cursors/selections on the change

v0.1.3 - added support for the mouse wheel


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)

Instead of the arrows can use your mouse wheel.

Forum Thread http://www.sublimetext.com/forum/viewtopic.php?f=5&t=2395

Support Multiple Selections

Inc-Dec-ValueInc-Dec-ValueInc-Dec-ValueInc-Dec-ValueInc-Dec-ValueInc-Dec-Value

Example of the correct values:

  • 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 (integer and floating-point) numbers and any text after them

    => 12px, -5em, 100%, 42sometext, (24), [12, -13], {77: -88}, 0.1em, 62.5%/1.5

  • hex colors

    => #f01 #f00456

    Pressing the key 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 #f01 the action applies to first character 'f'

    Pressing the key super+up/down(Linux) or super+alt+up/down(Windows & OSX) increases/decreases the total value of the hex color on +111/-111 or +111111/-111111 (regardless of the settings)

    Pressing the key super+alt+up/down(Linux) or super+ctrl+up/down(Windows) or super+alt+ctrl+up/down(OSX) swapping the color notation in CSS:

    from:

    color: rgba(0, 17, 34, 0.4);
    

    to:

    color: #012; /* alpha: 0.4 */
    

    again:

    color: rgba(0, 17, 34, 0.4);
    
  • 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.

  • opposite relations or cycled enumerations

    => true > false, True > False, FALSE > TRUE, left > right

    also

    => truE > false, tRUe > false, FaLsE > true, LeFT > right

    Pressing the key super+alt+up/down(Linux) or super+ctrl+up/down(Windows) or super+alt+ctrl+up/down(OSX) 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”

    Version 0.1.13 adds the ability to cycle through enum with Java capitalization

    => “centerX” > “centerY”, “screenLeft” > “screenRight”

    Version 0.1.21 fixed for values with few “-” and with “(” “)”

    => “last-child” > “last-of-type” > “nth-child()”

    Example of settings see in 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(Linux) or super+alt+up(Windows & OSX) makes the word in UPPERCASE.

    Pressing the key alt+down or super+down(Linux) or super+alt+down(Windows & OSX) 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

{
    "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"]
    ,   ["block", "none", "inline", "inline-block"]
    ,   ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]
    ]

,   "force_use_upper_case_for_hex_color": false
,   "autosave": false
,   "space_after_comma_in_rgba": true
,   "RGB_instead_RGBA": false
}

Default (Linux).sublime-keymap

[
    { "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" } }
]

Copyright

Copyright © 2011 Razumenko Maksim razumenko.maksim@gmail.com

Minor contrib by

MIT License, see http://opensource.org/licenses/MIT