Bracket Autocomplete {} causes headaches as it moves cursor to end of line

Can you guys adjust the bracket auto complete?

when I type a loop or function and open the bracket storm autocompletes the closing bracket but moves the cursor to the end of the line. Then I press enter and I am not inside my loop or function. I have to go back up and press enter again inside the bracket to get inside the loop or function.

I don't think it was always like this. It really slows things down.

public function autoComplete(){}|<--cursor is placed here instead of inside the closing bracket
Comment actions Permalink

Hi there,

It works fine here (checked in the latest PhpStorm 2021.2).

Could be:

  • Your settings: show what you have at "Settings/Preferences | Editor | General | Smart Keys"
  • Some plugin interfering: try disabling ALL custom plugins, restart IDE and see if it makes any difference. If it works OK -- enable a few plugins at a time until you spot the bad one.


Side notes. Do you know that:

  • after you typed "public function autoComplete()" you can press Ctrl+Shift+Enter (or whatever other shortcut you may have there in your Keymap for "Code | Code Completion | Complete Current Statement" action) and it will insert the missing {}
  • you cam use Live Template to write function/loop definition where the whole snippet is inserted (with needed {} in the right place) and you just go through the placeholders to fill the missing bits.
Comment actions Permalink

I figured out what I was doing.. 

When I open a bracket for an array or function/loop I automatically hit the closing bracket.. So 2 key presses really fast open and close.

This puts the cursor at the end of the line, which i would think is expected behavior.. Just need to retrain myself to only open :-)



Please sign in to leave a comment.