PhpStorm 中的多个光标,如 Sublime Text 3? [英] Multiple cursors in PhpStorm like Sublime Text 3?
问题描述
您可以使用 Alt + Click
在 PhpStorm 中设置多个光标,但是如果您想快速制作一个像这样的列表的数组,则单击的行太多了:(来自 Sublime Text 的示例3)
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)
在 Sublime Text 3 中,您只需选择所有行并点击 Ctrl + Shift + L
,它将在每行的末尾设置光标,然后您可以点击 Home
> 按钮将光标设置在开头或其他位置.
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.
我在文档中找不到任何东西...也许有人知道如何在 PHPStorm 中做到这一点,或者至少如何使用宏或其他东西制作一些键盘快捷键?
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?
推荐答案
此类操作从 2020.2 版本 开始可用 -- 参见 IDEA-122181.
Such action is available from 2020.2 version -- see IDEA-122181.
它被称为 Add Caret Per Selected Line
并且默认情况下在 Windows 上有 Alt + Shift + G 快捷方式(⌥⇧G 在 Mac 上).
It's called Add Caret Per Selected Line
and by default has Alt + Shift + G shortcut on Windows (⌥⇧G on Mac).
还有 Extra Actions 插件:它声称这样做以及其他一些事情.
There is also Extra Actions plugin: it claims to do that and few other things.
当前的替代方案(比提到的 Alt + Click 要容易得多):
Current alternatives (that are much easier than the mentioned Alt + Click):
只需进入列选择模式(从
Edit
菜单,Alt + Shift + Insert 在 Windows 上,Cmd+ Shift + 8(在 Mac 上).完成后退出该模式.
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):
- 在 Windows 上:按 Ctrl 两次,然后不松开,按 Up 或 Down 箭头键.
- 在 Mac 上:按 Ctrl + Shift + 向下/Ctrl + Shift + 向上
- 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
您也可以通过按 Shift + Alt 并拖动插入符号来进行多项选择.
You can also make a multiple selection by pressing Shift + Alt and dragging the caret.
来自 https://www.jetbrains.com/help/phpstorm/working-with-source-code.html#multiple_cursor
这篇关于PhpStorm 中的多个光标,如 Sublime Text 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!