How can I expand multi-line selection to full lines in PHPStorm?

牧云@^-^@ 提交于 2019-12-22 05:07:26

问题


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.


回答1:


I was also missing this functionality in PHPStorm which I used often in Sublime. Still it aint possible to set a caret by keyboard on all selected lines. This is as close as I could get it and it does the trick for me.

Go to settings > Keymap. Search for Clone Caret Above/Below. I'm working on a Mac so I set up the buttons like this

It is looking a bit weird but it is CMD+SHIFT+CTRL+ARROW_UP for Clone Caret Above and CMD+SHIFT+CTRL+ARROW_DOWN for Clone Caret Below

And then click on Apply and it will work




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/26165160/how-can-i-expand-multi-line-selection-to-full-lines-in-phpstorm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!