Ludder
Ludder

Reputation: 2733

How can I expand multi-line selection to full lines in PHPStorm (IntelliJ IDEA)?

In Sublime Text I can arbitrarily select a set of lines and then use ⌘+L to expand the selection to the full lines. Is there a similar command in PHPStorm / WebStorm? (I'd like to map that command to a keyboard shortcut.)

I know PHPStorm has the option "Select Line at Caret", but that selects only one line.

Upvotes: 10

Views: 15046

Answers (4)

caramba
caramba

Reputation: 22480

Update

Nowadays (welcome 2020) Go to Preferences > Keymap. Change or add the value to Add Carets to Ends of Selected Lines => CMD+SHIFT+L to have it behave like Sublime Text so it looks like

enter image description here

Old Answer This is as close as I could get it (before 2020):

Go to Preferences > Keymap. Search for Clone Caret Above/Below.

On a Mac, it looks like this enter image description here

The keys are:

CMD+SHIFT+CTRL+ARROW_UP for Clone Caret Above

CMD+SHIFT+CTRL+ARROW_DOWN for Clone Caret Below

Click on Apply and it will work

enter image description here

Upvotes: 14

DJDaveMark
DJDaveMark

Reputation: 2855

With WebStorm 11 (at least) the multi-caret keyboard shortcut is:

Ctrl then Ctrl+Arrow Up (or click & drag with the middle mouse button/scroll wheel)

then to select the full lines:

Home then Shift+End

which you could even create as a macro with a keyboard shortcut.

I used to accidentally activate the multi-caret all the time (I scroll with Ctrl+Up/Down), so I knew how to do part of it, but it took me ages to figure out that extra Ctrl tap at the beginning.

Upvotes: 6

mark.sagikazar
mark.sagikazar

Reputation: 1042

This is currently not possible with a selection. However, you can still do that from the keyboard. Instead of doing selections set up a shortcut for Clone Caret Above (Alt+Shift+U for me) and Clone Caret Bellow (Alt+Shift+D for me). This allows to go up or down a line and add a caret there. So instead of selecting each line, you directly move the caret there and clone it.

I am also coming from Sublime Text and missing that feature, but this worked also pretty well.

Upvotes: 1

Darek Kay
Darek Kay

Reputation: 16649

Hold down Alt + Shift and left click on the lines you want to select. This will put multiple cursors on the editor. Now you can use the Select Line at Caret option you mentioned to select all those lines.

You can find more about multiple selections here.

Upvotes: 3

Related Questions