Reputation: 5509
How can I indent HTML or PHP code in notepad ++ editor to organize my code better?
Upvotes: 15
Views: 55576
Reputation: 12672
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.
Upvotes: 6
Reputation:
Select part of your code or any text and then press tab, it will indent all selected lines. Press shift + tab for unindent.
Upvotes: 0
Reputation: 7722
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.
Upvotes: 2
Reputation: 324610
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.
Upvotes: 2