Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VScode formatter, keep open bracket at same line (PHP)

Tags:

I have enable the "editor.formatOnSave" setting but in php files when the code is formate, all the open brackets are going to a new line. i just want them to stay in the same line ex

function test{  } 

not

function test {  } 

I am looking for a solution all day but i cant find anything

like image 642
Alt-Rock Ninja Avatar asked Mar 27 '19 12:03

Alt-Rock Ninja


People also ask

How do I arrange PHP code in Visual Studio?

Add the extension Format HTML in PHP to Visual Studio Code. Or search in extensions with "format HTML in PHP". After reload, use Shift + Alt + F .


1 Answers

If you want to have your php code formatted like this

function test {  } 

then use intelephense with the following settings.

  "intelephense.format.braces": "k&r" 

Edit

As @Pinonirvana said in his answer, you can now do this through the GUI.
You'll find this information under du user settings:

Short key -> Ctrl+,

or

File > Preferences > Settings

enter image description here

like image 141
Raphaël Balet Avatar answered Oct 08 '22 11:10

Raphaël Balet