Multi-caret in Android Studio
Knowing keyboard shortcuts is important. They save you time and help you achieve more in less time. If you need convincing, I highly recommend watching ‘Mouseless Driven Development’ by Hadi Hariri.
This blog post is about one such feature of Android Studio (or any JetBrains IDE for that matter) which not a lot of people know about — multi-caret selection. A lot of my friends and colleagues who I pair-program with feel amazed by it and always ask “What was that!?”, so I decided to write about it to help them and everyone out there know about these.
Why use it? Because sometimes you need to replace just a few instances of a word/pattern and find & replace is not very useful.
Alt + J / Control + G (Select next occurrence)
Select next occurrence of the currently selected text. If no text is selected, the current word with cursor is selected.
Alt + Shift + J / Control +Shift + G (Unselect current occurrence)
Unselect current occurrence of selected text.
Alt + Shift + Ctrl + J / Control + Command + G (Select all occurrences)
Select all occurrences of the word in current file
Alt + click & scroll / Option + click & scroll (Multiple cursors in column)
Select a column of text in current file
Alt + Shift + clicks / Option + Shift + clicks (Spawn caret at click position)
Spawn carets across file at click position, even in the same word.
Hope it helps!
Originally posted on Medium link