Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php: auto indent the whole code?

isnt there any software/plugin to netbeans/eclipse that auto indent the whole code after i've inserted it?

not just indent when i press ENTER for new function.

i want to paste in a code for example without indents and it will auto indent everything automatically since it can recognize what language is used.

should save a lot of time.

like image 808
ajsie Avatar asked Dec 19 '09 12:12

ajsie


People also ask

How do I indent PHP code?

Spacing and indentation should be consistent throughout your code. Many developers choose to use 4-space or 2-space indentation. In PHP, each nested statement (e.g., a statement following a "{" brace) should be indented exactly once more than the previous line's indentation.

Is PHP indent sensitive?

PHP is whitespace insensitive PHP whitespace insensitive means that it almost never matters how many whitespace characters you have in a row. one whitespace character is the same as many such characters.

What is auto indent?

Automatic indenting occurs when you insert new lines. • None No special indenting occurs. Source Insight will return the insertion point to the very beginning of the next line when you insert a new line or word wrap.

How do you Auto Arrange codes in atom?

Auto Indent Luckily, Atom has you covered. Select the code and head to Edit > Lines > Auto Indent. This should copy the current indentation on the file to correct your code. To speed this up, I created a custom keyboard shortcut, enabling me to use Ctrl + Cmd + ] at any point.


1 Answers

In Zend Studio (and I guess in Eclipse with PDT as well), you can right click your pasted document in the editor view and select Source Format. Rules for source formatting are edited in Windows Preferences PHP Code Style Formatter. You can select Code Conventions like PEAR or ZF there by default or invent your own.

If you just want to indent some selected lines of code back and forth you select it and hit tab (or shift tab to unindent). This will not resolve any nested code though. Use Ctrl Shift F for that (thanks to Paul Lammertsma for pointing that out).

like image 55
Gordon Avatar answered Nov 15 '22 20:11

Gordon