Source code of the intellij IDEA Shifter plugin
This is a plugin for the various Jetbrains IDEs, working in IntelliJ IDEA, PhpStorm, WebStorm, PyCharm, RubyMine, AppCode, CLion, Gogland, DataGrip, Rider and Android Studio
When evoked, shifter detects the type of selection, line or keyword at caret and shifts it “up” or “down”.
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.
To shift values instantly multiple times, there are additional “Shift More” actions, the amount of repetitions can be configured in the plugin configurations (default: 10).
Shifter adds the following editing tools (you can change the keymap in the IDE preferences):
- Ctrl+Shift+Alt+Comma – Shift-Down
- Ctrl+Shift+Alt+Period – Shift-Up
- Ctrl+Shift+Alt+J – Shift-Down More
- Ctrl+Shift+Alt+K – Shift-Up More
Mac Users: On Macs, the keyboard shortcuts are Comma or Period key together with Shift+Alt+Cmd
Supported generic shifting types:
- Shifting a multi-line selection sorts the lines alphabetically ascending/descending.
- Shifting a single-line selection, that is a comma separated list, sorts the items ascending/descending. Shifting a selection of two words, separated by a space character, flips the order of those words.
- Shifting a single-line selection, that is a tupel, toggles the items’ order (delimiters: “:”, “|”, ", ", " – ", " + ", " < ", " > ", " <= ", " >= ", " == ", " != ", " = ", " ! ", " || ")
- Shifting a selection within a single line (that is not CSV), detects and swaps characters: single quote vs. double quote OR slash vs. backslash
- Shifting a selection that contains two terms, separated by " " or “|” or " : ", swaps the order of the terms
- Numeric values and roman numerals – Increments/decrements numbers by 1
- 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
- Selected (from questionmark on) ternary expressions – Swaps “than” and “else” statements
- PHP variables – Shifts to alphabetically next/previous variable name 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 of PHP concatenation from two strings / variables – Toggles order of the concatenated parts
- Selected line of code ending with a trailing //-comment – Moves the comment into a new line before the code
- Strings wrapped in single/double quotes and backticks – Shifts to alphabetically next/previous quoted string found in current document
- 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)
- 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
- Strings ending with numbers – increments/decrements the postfix
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
- 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..)
- Metasyntax 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
Read full changelog: https://github.com/kstenschke/shifter-plugin/blob/master/CHANGELOG.textile
Thanks for their input, ideas, help or other contribution
- Andriy Bazanov
- Eike Thies
- John Fearnside from Moz
- John Lindquist from Jetbrains
- Joshua David
- Nicolaj Schumacher
- Vojtěch Krása
- Srdjan Marković
- Steve Smith from NOLS
- Yann Cebron from Jetbrains
Third Party Acknowledgment
Shifter uses the following third party components:
- NaturalOrderComparator by Pierre-Luc Paour
Copyright 2011-2017 Kay Stenschke
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.