问题
How can I indent HTML or PHP code in notepad ++ editor to organize my code better?
回答1:
If you want auto-formatting, look at SourceFormatX, which is a paid plug-in for Notepad++.
Other than that, there are a few free plug-ins available on the Notepad++ Wiki which will format either HTML or PHP code.
回答2:
It is generally common practice to indent one level for each currently open "block". In PHP, a "block" is simply code between {
and }
. In HTML, a "block" is any tag that is not closed on the same line.
In Notepad++ (and many other code editors) you can select several lines of code and hit Tab to indent the entire selection (or Shift+Tab to outdent it). This should help keep your code tidy.
Another thing to note is that Notepad++ can collapse blocks for you. Next to the line numbers, you should see a tree with [-]
boxes. You can click those to collapse the block they're marking, allowing you to get a better overview of your code.
回答3:
If you need a plugin to format your HTML, it is not clear if you only want to tab, but in common sense, I suppose you're looking for a software to reindent the code. There is a plugin Tidy2 in:
https://github.com/davegb3/NppTidy2
With this you can reformat all your HTML code, and change how to do it, which is often interesting.
回答4:
Select part of your code or any text and then press tab, it will indent all selected lines. Press shift + tab for unindent.
来源:https://stackoverflow.com/questions/14678080/how-can-i-indent-html-or-php-code-in-notepad-editor