Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get multiple cursors (carets) at each find result in Intellij Idea editors?

I want to select all the string resource keys that contain the word "key" at the same time. I had a hard time figuring this out so I figured I'd post this for others. The multicursor documentation doesn't address this question.

An excerpt of the file I wanted to select from.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- User Preferences -->    
    <string name="preference_key_pedigree_enable_offline_mode">Pref.OfflineMode</string>
    <string name="preference_title_pedigree_enable_offline_mode">Offline Mode</string>
    <string name="preference_summary_on_pedigree_enable_offline_mode">Scans work without an internet connection, don\'t require a VIN and can\'t be saved.</string>
    <string name="preference_summary_off_pedigree_enable_offline_mode">Scan results will be sent to the server.</string>
    <string name="preference_default_pedigree_enable_offline_mode">false</string>

    <string name="preference_key_pedigree_hide_cleared_dtcs">pref_pedigree_hide_cleared_dtcs</string>
    <string name="preference_title_pedigree_hide_cleared_dtcs">Hide Cleared DTCs</string>
    <string name="preference_summary_on_pedigree_hide_cleared_dtcs">DTC\'s are hidden after they\'ve been cleared</string>
    <string name="preference_summary_off_pedigree_hide_cleared_dtcs">DTC\'s are still shown after they\'ve been cleared</string>
    <string name="preference_default_pedigree_hide_cleared_dtcs">true</string>

    <string name="preference_key_analytics_global_opt_out">pref_analytics_global_opt_out</string>
    <string name="preference_title_analytics_global_opt_out">Analytics Opt-Out</string>
    <string name="preference_summary_on_analytics_global_opt_out">Analytics switched off.</string>
    <string name="preference_summary_off_analytics_global_opt_out">Crash reports and usage statistics are being used to improve this app.</string>
    <string name="preference_default_analytics_global_opt_out">false</string>
</resources>
like image 228
Jon Avatar asked Oct 19 '16 22:10

Jon


People also ask

How do I get multiple cursors in Intellij?

Alt+Shift+Click at the target location to add another caret. Alt+Shift+Click at one of the multiple carets to remove it.

How do I get rid of multiple cursors?

Add or remove carets at selected locations using mouse Ctrl+Alt+Click at the target location to add another caret. Ctrl+Alt+Click at one of the multiple carets to remove it. The last caret will not be removed.

How do I change all occurrences in Intellij?

Press Ctrl + Alt + Shift + J on Windows/Linux, and ⌘ + ^ + G on macOS. After the selection is complete, you can start editing all the fragments as if they were all the same one.


2 Answers

Intellij Idea calls this multiselection.

Select the term to search for with your cursor. In my example, the word key
enter image description here
Next, select all occurrences:

  • press ctrl+alt+shift+J
  • alternatively use the find action menu ctrl+shift+A action search screenshot

screenshot of selection

Now you can expand your selection (ctrl+W) to the entire keys, and then copy and past elsewhere.

like image 54
Jon Avatar answered Sep 27 '22 01:09

Jon


Android Studio : Default Keyboard

-> : Column selection mode = Alt + Shift + Insert (Selection with Multi Cursor enable|Disable)
-> : Find and select all occurrences with cursor = Ctrl + Alt + Shift + J
-> : Multi cursor(Any line) = Alt + Shift + Mouse Click and Alt + Hold Mouse click
-> : Select Entire Word = Ctrl + W


Android Studio : eclipse Keyboard

To search terms with multi cursor.
Just set eclipse keyboard in Android studio.
Just Select terms and use shortcut like below.
PRESS : Ctrl + Alt + Y

like image 40
Bhupat Bathvar Avatar answered Sep 25 '22 01:09

Bhupat Bathvar