1

I'm looking for a way to format the spaces between symbols and keywords in emacs.

For example I'd like to change the following php code :

foreach($a as $b) {
}

into

foreach ($a as $b) {
}

All I've been able to find thus far are external tools to run from emacs.

Related : Auto formatting a PHP file in emacs.

I'd prefer that it did the formatting on indent, is this possible?

1 Answer 1

1

Indeed, I don't know of any such tool within Emacs. I'd be happy to accept submission for a package that does something like that on the fly. Maybe it could work a bit like electric-layout-mode?

Sign up to request clarification or add additional context in comments.

2 Comments

Interesting, I'll look into electric-layout-mode and see if it can be used/repurposed for what I need, I'll post back with my findings.
Actually, in the mean time, I bumped into smart-operator which does something similar, tho not for parentheses but for infix operators.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.