15

How can I indent HTML or PHP code in notepad ++ editor to organize my code better?

2

4 Answers 4

6

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.

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

1 Comment

one of the link "Notepad++ Wiki" is not working in the above answer.
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.

Comments

2

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.

Comments

0

Select part of your code or any text and then press tab, it will indent all selected lines. Press shift + tab for unindent.

Comments

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.