How to select multiple places in code in Android Studio ?
I want to insert the same text in multiple places in my source code. Like a have more than one mouse cursor. I used to do it in VS2012 so easily though not sure how to do it in Android Studio ?
I found how and lets share this cool feature with you. I found three cool features:
For multiple selection just hold alt + shift then select whenever you want to change by mouse click then type some thing you can write at multiple places at the same time. Another cool feature is column selection. This lets you to click in a great manner and greatly of help especially when you are refactoring.
In most systems it works with holding middleMouseButton
and dragging over your code and in others it works by holding alt and selecting code it acts like below:
https://i.stack.imgur.com/SboDc.gif
the third cool feature is sublime selection it finds the same word in code and let you change that or append that easily. you can do that by pressing alt + j on Windows / Linux and ctrl + g in mac. Look how it works:
https://i.stack.imgur.com/GGR8I.gif
Also as @Narayana said in comments, Ctrl + Shift + Alt + j selects all occurrences in one shot, for one-shot refactoring.
You can use Alt + Shift and click multiple locations to for multiple cursor.
To select similar occurrences in files use Alt + j.
For more details : Click Here
Multiline Caret (without mouse)
Windows: CTRL + CTRL(Hold) + ↑ / ↓
Mac: ⌘ + ⌘(Hold) + ↑ / ↓
ESC will end multiline mode.
Change Multi-caret Hotkey
To add a custom Keymap, CTRL+SHIFT+A, type keymap
and click on the one with Settings
as subtext. Search for Clone Caret Above
and Clone Caret Below
.
I mapped mine to ALT+SHIFT+↑ / ↓.
Bonus
Try holding combinations of CTRL, SHIFT, and arrows for improved selection power.
For both Mac and Windows, just open the Context Menu and click on the "Column selection mode" to enable or disable the behaviour..
https://i.stack.imgur.com/BzSbL.png
Press Shift
+ Alt
+ Insert
combination to edit in Column selection mode.
Shift
+ Alt
+ Insert
again to exit edit mode :). In this case a cursor can move up-down in usual way, not over spaces.
On a mac I like to do ⌥ (option) + shift + mouse click on multiple lines in Android Studio 3.1.3.
On a MacOS you can use:
Tap: Control
+ Command
+ G
- Select all the same value
Tap: Control
+ G
- Every tap combination select the new same value
Hold: Option
+ Mouse Click
- Select multiline with a mouse
Hold: Option
+ Shift
and Tap: Mouse Click
- duplicate cursor for a each tap place
Use the following:
ALT
+ SHIFT
on Mac , hold OPTION + SHIFT
then use the mouse to highlight what you want to select
On Windows, you can try a plugin whose name is ConyEdit. It has a great column mode based on regular expression.
I'm using android studio arctic fox and pressing Alt alone and then selecting code is working properly in windows.
Success story sharing
Ctrl
+Shift
+Alt
+j
selects all occurrences in one shot, for one-shot refactoring.SHIFT
+F6
to refactor rename almost anything and everything in Android Studio. Doing so will refactor it in other files too.