Skip to content
Vladimir Schneider edited this page Jan 24, 2020 · 24 revisions

Missing In Actions

You can download it on the JetBrains plugin page.

IntelliJ development tools are the best of breed when it comes to language support, refactoring and the rest of intelligent language features but I find they suffer in their text editing capabilities, especially when it comes multiple caret editing. In code editing I find there many occasions for text transformation that can be addressed with multiple caret editing more efficiently than syntax based refactoring.

This plugin adds features for text based code editing to make it more efficient with less distractions and keystrokes.

Shared Multi-Caret Clipboard Content

Multi-caret clipboard content can be shared between IDE instances so you can copy in one IDE and paste in another IDE, with caret information intact.

Auto Line Selections

Selects full lines without loosing time or column position by moving the caret to the start of line when selecting or pasting full lines.

Choose whether you want to paste full line selections: above or below the current line regardless of the caret's column.

Missing In Actions

Smart Paste

Adjust pasted text when pasting identifiers by matching case and style of identifier at destination. Undo will reverse the automatic changes for the 10% of cases where the results are not what is desired.

Copying myColumnData and pasting it over DEFAULT_VALUE will result in COLUMN_DATA, reverse the order and the result is myDefaultValue.

Supports: camelCase, PascalCase, snake_case, SCREAMING_SNAKE_CASE, dash-case, dot.case, slash/case

Default prefixes: my, our, is, get, set to allow pasting over member fields, static fields, getters and setters.

Mia Smart Paste Multi Caret

Caret Search/Spawn

Actions which use the current caret text content for search criteria:

  • If caret is on a space then search for first non-space character

  • If caret is on an identifier (alpha-numeric) then search for occurrence of the identifier text in the directions of the search.

  • Otherwise search for the character at caret

Behaviour of these actions also depends on whether the actions are applied to a single caret or multiple carets:

When applied to single caret

Will spawn new carets at locations and select text in between. Text search is limited to current selection or the current caret line if no selection.

When applied to multiple carets

Search criteria is determined by the "Primary Caret" and applied to all other carets, moving them to the first match of the search criteria or removing the carets if no match is found for a caret.

When this actions is initiated the plugin enters into a special mode. In this mode caret movement keys move the original caret position to change the start position for the search. Any non-caret movement action or typing will exit the mode, leaving only the "matched" location carets.

⚠️ while in this mode you have both the start and matched location carets on the screen. For IDE versions 2017 and later these carets are displayed in different color and/or thickness to allow them to be easily distinguished. In older IDE versions this mode is very difficult to use because you cannot distinguish the search start from match found carets.

You can customize the colors used for highlighted words in settings/preferences depending on your OS, under Tools > Missing In Actions in the Extras tab:

Tools Settings Extras

In the examples below start position carets are in Word_RED and matched position in Word_BLUE, while normal mode carets are BLACK with the primary caret being thicker.

Starting with these carets:

Caret_search

Use the search forward button Forward Search to get:

Caret_search_1

Or start with these carets:

Caret_search_2

And use the search backwards button Backward Search

To get the unexciting:

Caret_search_3

But then use the move caret to end of line key to move the start of search and get a more interesting result:

Caret_search_4

As you can see the "matched" carets are now at the end of the last caret word on each line. You can start typing or invoke a non-movement action to keep the matched carets or click the Accept Search button to get the same effect without invoking any actions:

Caret_search_5

The reason all carets move to the end of the word caret is because the primary caret when the search backward actions was invoked was preceeded by caret but was not at on a word boundary. This means that the search will look for caret that also does not end on a word boundary.

You can also modify the search criteria and search direction through the Search Carets Options action or the toolbar button Icons Search Options to open a dialog which has a preview of the carets and text from the file and shows results of changes you make.

Caret Search Options

Enhanced Paste from History

  • combine, arrange and reverse the order of content entries

  • combine multiple clipboard contents with caret information intact

  • paste and re-create multiple carets from information already stored on the clipboard

  • duplicate line/block for each caret in the clipboard content and put a caret on the first line of the block, ready for multi-caret select and paste

  • duplicate line/block for each caret in the clipboard content for multiple caret selections and paste content into each selection

  • splice individual entries into delimited list, optionally quoting each entry. Useful in JavaScript for converting multi-caret copied property names into a quoted property name array list.

  • see caret information stored on the clipboard for each content entry

Paste From History Details

Line Isolation mode

Great when you copy a method or block of code for modification and want to avoid making changes to the wrong text. Since both of these blocks of code look the same it is very easy to start modifying the copy, then scroll to another place in the code for reference or to gather more code only to return to the original part of the code and start applying modifications.

Use Add Isolated Lines button on the copied text so that it stands out from the rest of the file. You can always add to isolated lines using the same button or remove some isolated lines by using Remove Isolated Lines or temporarily toggle this mode without loosing isolated line information using

Isolated Lines

Batch Search/Replace Tool Window

Sometimes you need to replace more than just one string across many files. For this the batch search/replace tool window can help. It makes changes on one file at a time but with any number of search/replace string combinations.

This feature was created to help with major name refactoring on a project with changes needed to MySQL database, Scala/Play/Slick middleware and React JavaScript front end. The renaming affected 130+ "names" across 70+ tables and 300+ files. In most cases the name changes needed to be analyzed before making the decision whether the change applied. Having a multi-string list with location highlights in files made the effort manageable and verifiable, allowing completion in about two weeks.

Batch_Replace.png

Each line in the Search text pane is will be used as search text, each corresponding line in the replace pane will be used as its replacement.

The options pane holds options for the search string. Each option is a character, invalid characters are ignored:

  • c - case sensitive search
  • i - case insensitive search
  • w - word (begin/end word boundary, same as be)
  • b - beginning of word boundary
  • e - end of word boundary
  • - - when in the first column will disable search/replace pair from being used
  • # - start of comment, all text following it is ignored

If highlighting text panels is enabled, each found search string will highlight the word in the editor according to its position in the search panel using the Highlight Words color gradients. Strings which have no match in the current file will show up as IGNORED which is usually shown as faint text.

⚠️ Bulk Search/Replace tool window disables the Highlight Words feature while it is active. To show highlight words instead of the bulk search string highlights, hide the tool window by clicking on its tab.

You can define presets which store the options and text for bulk search replace and associate it with a name. This allows having change sets which can be applied in different contexts.

Entering a preset name and clicking Save will save the current settings under the preset name. If the preset already exists it will be overwritten, if it does not it will be created. See Managing Presets.

Panel Toolbar Buttons

Toolbar_buttons

  • Toolbar_button_sort_up - sort lines ascending, sorts all three text panes based on the strings in the pane for which the sort button was clicked. Case sensitivity of the sort is selected by the current state of the Case checkbox.

  • Toolbar_button_sort_down - sort lines descending, sorts all three text panes based on the strings in the pane for which the sort button was clicked. Case sensitivity of the sort is selected by the current state of the Case checkbox.

  • Toolbar_button_tandem_edit_off / Toolbar_button_tandem_edit_on - toggle tandem edit mode. When locked, insert/delete line operations in any of the text panels apply to the other two panels. When on also adds a visible border around text panels as an indicator that all three panels will be affected.

  • Toolbar_button_copy_regex - copy regex representing the search strings to the clipboard. Easy way to search for all strings across files using IDE search in files functionality.

  • Paste - if the clipboard contains two multi-caret entries uses the current clipboard as the replacement strings and the one previous to it as search strings. Used when you have search and replace strings on the same line, such as in a table or a list. Use case:

    1. select search text strings using multi-caret mode and copy to clipboard,
    2. select replacement text using multi-caret mode and copy to clipboard.
    3. Hit Paste to transfer them to the search and replace panels.
  • Toolbar_button_show_highlights - toggle highlighting search/replace/options panel text lines. Only lines whose search string is found in the file will be highlighted with those that are not found displayed as "unused variable" color. A quick way to tell if anything in the current file matches.

  • Swap - swap search and replace panel contents.

Managing Presets

Batch_Replace_Manage.png

Import/Export of presets and current settings is done via the Manage... drop down. XML format stores all settings. JSON only the preset name and associated search/replace texts. The JSON format is easier to create from scratch while XML is more useful as a persistence format.

Delete will delete the currently selected preset name from the list.

Clear All will delete all presets, clear all text panes.

Highlight Words

Use it to highlight range of text in all files, across all projects in the current IDE session. Handy when you have a set of identifiers in one list and want to validate that all are present in another part of the code or to see which of these are missing. A good example is an enum or a set of constants and their use in a switch statement in Java. Unlike language specific functionality uses only text matching and does not require syntactically correct code or language awareness.

Here is an example in one file but highlights work across all files;

Highlight_word

To see which constants are not part of the BOUNDARY_FLAGS constant, select them:

Highlight_word_1

and click to have them light up in all files and projects.

Highlight_word_2

You can also use the highlighted words to keep Keep Word Highlighted Carets carets whose selection is a highlighted word or to remove Remove Word Highlighted Carets carets whose selection is a highlighted word. These actions allow you to quickly adjust your multi-caret selection for copying or editing:

Select all identifiers:

Highlight_word_3

Remove Remove Word Highlighted Carets ones that select highlighted word to get the difference:

Highlight_word_4

Or keep Keep Word Highlighted Carets ones that select highlighted word to get the intersection:

Highlight_word_5

You can customize the colors used for highlighted words in settings/preferences depending on your OS, under Tools > Missing In Actions in the Extras tab:

Tools Settings Extras

When the number of highlighted words exceeds the defined colors, all older words will be highlighted by cycling through the last row of colors.

ℹ️ For light schemes it is best to vary the saturation keeping brightness at 100%, while for dark schemes it is best to vary the brightness keeping saturation constant.

Highlight_word_6

You can also select a single Hue by setting the Hue Steps to 1. In which case all highlights will use the single hue and as many saturation and brightness permutations as you select.

Highlight_word_7

then previously highlighted word example will look like this:

Highlight_word_8