Aligning PHP arrays with Emacs
PHP doesn’t require arrays to be aligned in a specific way, but certain coding standards will raise a warning if they’re aren’t aligned correctly. Doing this by hand can be a pain.
emacs-php-align is a small extension that can automatically align arrays. It’s not available on Melpa, but it’s fairly quick to setup.
Once it’s installed, calling M-x align-current
will align an array and turn this:
$my_array = array(
'key' => 'Value',
'key_two' => 'Another value',
'really_long_key' => 'Value',
'k' => 'Value',
);
into this:
$my_array = array(
'key' => 'Value',
'key_two' => 'Another value',
'really_long_key' => 'Value',
'k' => 'Value',
);