Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse PDT: How do I get it to format my PHP arrays like VIM?

I've been struggling to get Eclipse to format my php arrays like vim indentation does.

What eclipse does (press CTRL+SHIFT+F)

<?php
$array = array(
'key1' => 'value1',
'key2' => array(
'child_key1' => 'child_value1',
'child_key2' => 'child_value2',
),
);

What vim does (press keys:gg=G)

<?php
$array = array(
  'key1' => 'value1',
  'key2' => array(
    'child_key1' => 'child_value1',
    'child_key2' => 'child_value2',
    ),  
  );  

I've tried looking in Preferences>PHP>Code Style>Formatter and Preferences>PHP>Editor>Templates but haven't found anything.
Thanks in advance.
Kehan

like image 666
Kehan Avatar asked Dec 10 '22 18:12

Kehan


1 Answers

Check out this project. Put the jar file in your eclipse/dropins folder, and then you can go to preferences/php/code style/formatter. It has a cool "Align => column position in array" option under the "Miscellaneous" section (click the arrow on the options tab to expand) that does something similar to what you want. Use Ctrl-Shift-F to format an entire file, or right-click a selection and checkout the "Source->Format..." options.

http://de.sourceforge.jp/projects/pdt-tools/releases/?package_id=8764

like image 191
Dave Meybohm Avatar answered Dec 12 '22 08:12

Dave Meybohm