Search code examples
android-studiointellij-ideamulticursoreditingcolumn-selection

How to paste multi lines separately in multi cursor mode?


I like the column selection (multi-cursor) mode of Android studio which eases my editing task a lot when it came to some configuration files.

However, I want to know whether I can copy multiple lines and paste them separately to the end of other lines.

For example, I will select first 3 lines:

source line 1
source line 2
source line 3

And then put multiple cursors at the end of target lines and paste

target line 1,|
target line 2,|
target line 3,|

What I want to achieve is to get:

target line 1,srouce line 1
target line 2,srouce line 2
target line 3,srouce line 3

However, the real situation is the copied 3 lines will be pasted 3 times at the end of each target line.

Is it possible to do what I expected? Correct me if I am thinking anything that should never happen.


Solution

  • Copy the lines using multiple carets. You can do this by holding Alt/Option and dragging the mouse cursor. Or with the keyboard by pressing Alt/Option twice, and then without releasing it, press the up or down arrow keys to create multiple carets. Then hold Shift and the left or right arrow keys to select.

    When using multiple carets for both copying and pasting, you get the desired effect of pasting one item at every caret.