You can also do this using built-in key bindings without any changes to Intellij options:
How this is done:
Use the following (or equivalent) GNOME
key bindings:
- Highlight the first
=
(or any delimiter of your choosing) - Press Alt+j once for each additional = to
Add Selection for Next Occurrence
- Press Left once then make room by pressing Tab per the above GIF
- Press Alt+Shift+Insert to enter
Column Selection mode
- Press Alt+Shift+Insert again to exit
Column Selection mode
(notice selection is aligned). - Press Left twice then presss Ctrl+Shift+Right to select all white space to each =
- Press Shift+Left to exclude
=
from selection - Press Backspace and that will cause all of the uneven whitespace to truncate
After backspacing to where you want the columns aligned, you should now have something like:
someVar = someVal
someOtherVar = someVal
someOtherOtherVar = someVal
The nice thing about this approach is it’s general purpose; The above steps will align any text within whitespace so long as you choose a distinct delimiter each line contains only once, such as =
in the example given.
As noted previously, this example was performed using GNOME
key bindings. You are free to pick a different scheme in Settings
> Keymap
: