PhpStorm自动补全__construct方法时,如何让光标自动定位到括号内?
Fix: Make PhpStorm Place Cursor Between __construct Parentheses After Auto-Generation
Hey there! I totally get wanting that cursor to land exactly where you need it after generating a __construct method—no extra clicking to move it into the parentheses. Here's how you can tweak PhpStorm to do just that:
- Open PhpStorm's Settings: Use the keyboard shortcut
Ctrl+Alt+S(Windows/Linux) orCmd+,(Mac), or navigate to File > Settings from the top menu bar. - In the left sidebar, go to Editor > Live Templates.
- Expand the PHP group in the template list. Look for the live template that triggers when you type
__con(it’s usually tied directly to the__constructmagic method). - Click on this template to edit it. In the Template Text box, adjust the code so the
$END$placeholder (which defines where your cursor ends up) is placed inside the parentheses. A good example of the template text would be:public function __construct($END$) { $BODY$ } - Save your changes by clicking Apply then OK.
That’s it! Now when you type __con, select the __construct suggestion, and hit Enter—your cursor will be perfectly positioned between the () ready to add any constructor parameters you need.
内容的提问来源于stack exchange,提问作者panosru
相关产品推荐
相关产品推荐

