You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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) or Cmd+, (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 __construct magic 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:48:13