Shifter

Compatible with: IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine AppCode CLion Gogland DataGrip Rider Android Studio
26.04.2017
108 344
Detects type of selection, line or keyword at caret and shifts it "up" or "down" on keyboard shortcut. If there's only one shiftable word in a line, it can be shifted without the caret touching it. Lowercase/uppercase or lower case with upper first character of shifted words is maintained.

DEFAULT KEYBOARD SHORTCUTS
  • Ctrl+Shift+Alt+Comma - Shift Down
  • Ctrl+Shift+Alt+Period - Shift Up
  • Ctrl+Shift+Alt+K - Shift Up More*
  • Ctrl+Shift+Alt+J - Shift Down More*

Shift more: repeats shifting the selected value multiple times. The amount of repetitions can be configured in the plugin configuration (default: 10).

SHIFTING TYPES
Sorting
  • Shifting a multi-line selection sorts the lines alphabetically ascending/descending.
  • Shifting a single-line selection, that is a comma- or pipe-separated list, sorts the items ascending/descending.
  • Shifting a single-line selection, that is a tupel, flips the items' order (delimiters: ":", "|", ", ", " - ", " + ", " < ", " > ", " <= ", " >= ", " == ", " != ", " === ", " !== ", " || ")
  • Shifting a selection that is a camelCased (w/ lower or upper lead character) word pair, flips the order of the words.
  • Selected (from questionmark on) ternary expressions - Swaps "than" and "else" statements
  • Selection of PHP concatenation from two strings / variables - Toggles order of the concatenated parts
Numeric Shifting
  • Numeric values - Incrementing/decrementing numbers
  • Strings ending with numbers - increments/decrements the postfix
  • Numeric block selection: opens dialog to chose: 1. in/decrement each or: 2. replace by enumeration
  • UNIX (and millisecond based) timestamps - Increments/decrements by one day, shows a balloon info with the shifted date in human-readable format
  • CSS hex RGB colors - Shifts color value lighter/darker
  • CSS length values - Shifts numeric length values up/down by 1 (units: em, in, px, pt, cm, rem, vw, vh, vmin, vmax)
  • Increment/decrement roman numerals
String Manipulations
  • Shifting a selection within a single line: detects and swaps characters: single quote vs. double quote OR slash vs. backslash
  • Strings wrapped in single/double quotes and backticks - Shifts to alphabetically next/previous quoted string found in current document
  • Logical operators: toggles between (selected) "&&" and "||"
  • Encoding/decoding of HTML special characters
  • Single characters and string consisting from any amount of the same character can be shifted to the prev/next ASCII value
Code- and DOC Comments
  • Selection which is a block comment or multiple line-comments (e.g. PHP, JavaScript, C syntax) - toggle among comment type (//... vs. /*...*/). Merges multi-line comments into 1 line.
  • Selected line of code ending with a trailing //-comment - Moves the comment into a new line before the code
  • Selected HTML comment inside a PHP / PHTML file: converts it into a PHP block comment (and vice versa)
  • PHP DOC: Shifting a selected PHP doc comment block that contains @param comments w/ variable name but no data type, guesses and inserts data types
  • PHP DOC: Shifting while the caret is inside an @param line that contains no data type, inserts a data type (guessed from the variable name)
  • JsDOC: Shifting w/ the caret touching a data type that is not wrapped in curly brackets, inside an @param- adds the missing curly brackets
  • Selected JsDoc block: Convert "@return" into "@returns", add curly brackets around data types in "@param" and "@returns" lines, correct invalid data types into existing primitive data types (event => Object, int(eger) => number), guess and insert missing data type to "@param" and "@returns" lines, reduce empty JsDoc lines
PHP and JavaScript
  • PHP variables - Shifts to alphabetically next/previous variable found in current document ("shift more" shifts until first variable with a different first letter)
  • Selected PHP array - Shifts among long and shorthand syntax (PHP >= 5.4)
  • Selection which is a Sizzle-Selector - Converts the selector into a corresponding JavaScript variable declaration
  • Selection of multiple JavaScript var declarations in succession - are joined into multiple comma-separated declarations
Dictionaric Keyword Shifting
Shifter comes with a customizable, file extension specific and globally usable dictionary of shiftable keywords. Some keyword types from the default dictionary:
  • PHP core magical constants - Shifts PHP's magic constants (__FILE__/__LINE__ etc.)
  • CSS orientations and positioning: top/right/bottom/left and absolute/relative, and geographical directions (north/east/south/west)
  • Accessibility types: public/private/protected
  • MySql data types: Shifts to next bigger/smaller numeric/string type
  • Primitive data types of Java, JavaScript, PHP, Objective-C
  • Doc comment tags (Java, JavaScript, PHP)
  • JavaScript event types (mouse, keyboard, frame/object, form, control, touch)
  • Named colors from the sRGB color space (white/lightgray/gray...)
  • Text styles (bold, italic...)
  • Web image (gif/jpg/png) and audio (au/aif/wav etc.) format extensions
  • Full and abbreviated names of months and weekdays and units of time
  • Logical operators (and/or/xor/not), arithmetic operations (addition/subtraction...) and arithmetic elements (sum/difference/product..)
  • Meta-syntax terms: foo/bar/baz...
  • Names of common data collection types (list/set/bag/dictionary/tree...)
  • Names of numbers (one/two/three etc.) and ordinal numbers (first/second/third etc.)
  • Boolean (paired) keyword values - Toggles true/false, on/off, yes/no (e.g. Objective-C), shown/hidden, show/hide, positive/negative, from/until, enable(d)/disable(d), pass/fail, min/max, expand/collapse, asc/desc, first/last

Please note: This plugin is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

Download plugin

Recent change notes

  • 1.6.0
    • Added: Correct selected invalid JsDoc block comment - convert "@return" into "@returns", add curly brackets around data types in "@param" and "@returns" lines, correct invalid data types into existing primitive data types (bool => boolean, event => Object, int(eger) => number), guess and insert missing data type into "@param" and "@returns" lines, reduce empty JsDoc lines
    • Added: Shift invalid JsDoc "@return" statement at caret into "@returns"
    • Shifted DOC block comment in PHP and JavaScript: reformat DOC block after correction
    • Added: Timestamp shifting unit (seconds or milliseconds) can be specified per file type in plugin settings
    • Improved: Better case maintaining of shifted words
    • Changed: Grouped shifting types in features list for easier comprehensibility
  • 1.5.5
    • Added: Add missing curly brackets around data type at caret in jsDoc @param line
    • Added: Mode selection popup when selection is both: sortable list, swappable quote signs
    • Added: Mode selection popup when selection is both: PHP concatenation (order can be toggled), swappable quote signs
    • Improved: Sorting a selection of lines w/ common delimiter no longer removes leading whitespace
  • 1.5.4
    • Added: Flip order of selected camelCase (w/ lower or upper lead character) string that is a word pair
    • Improved: PHP DOC comment data type detection
    • Improved: Tupel detection (both items must be non empty)
    • Bugfix: Numeric postfix shifting ("a99" was shifted into "a910" instead of "a100")
  • 1.5.3 Bugfix: Fixed null pointer exception on Ubuntu during plugin initialization. Thanks to Vojtěch Krása
  • 1.5.2
    • Added to multiple selected single-line comment shifting: Convert to block comment
    • Added to multiple selected single-line comment shifting: Merge into one comment
    • Added to multiple selected single-line comment shifting: Sort comments ascending/descending

...Read full changelog on github

General usage instructions

Ctrl+Shift+Alt+Comma - Shift down word at caret / in line / sort selected lines ascending Ctrl+Shift+Alt+Period - Shift up word at caret / in line / sort selected lines descending