问题
You can use Alt + Click
to set multiple cursors in PhpStorm but if you want to quickly make an array of some list like this, it's simply too many lines to click: (example from Sublime Text 3)
In Sublime Text 3 you simply select all the lines and hit Ctrl + Shift + L
and it will set cursors at the end of each line and then you can hit Home
button to set the cursors at the beginning or whatever.
I can't find anything in docs... maybe someone knows how to do this in PHPStorm or at least how to make some keyboard shortcut with macro or something?
回答1:
Such action is available from 2020.2 version -- see IDEA-122181.
It's called Add Caret Per Selected Line
and by default has Alt + Shift + G shortcut on Windows (⌥⇧G on Mac).
There is also Extra Actions plugin: it claims to do that and few other things.
Current alternatives (that are much easier than the mentioned Alt + Click):
Just go into Column Selection Mode (from
Edit
menu, Alt + Shift + Insert on Windows, Cmd + Shift + 8 on Mac). Exit that mode when done.Alternatively, to add multiple carets (Clone Caret Below / Above):
- On Windows: Press Ctrl twice, and then without releasing it, press the Up or Down arrow keys.
- On Mac: Press Ctrl + Shift + Down / Ctrl + Shift + Up
You can also make a multiple selection by pressing Shift + Alt and dragging the caret.
From https://www.jetbrains.com/help/phpstorm/working-with-source-code.html#multiple_cursor
来源:https://stackoverflow.com/questions/62660713/multiple-cursors-in-phpstorm-like-sublime-text-3