How can I indent HTML or PHP code in Notepad ++ editor?

僤鯓⒐⒋嵵緔 提交于 2021-02-04 22:11:37

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!