How can I indent HTML or PHP code in notepad ++ editor to organize my code better?
如何在notepad ++编辑器中缩进HTML或PHP代码以更好地组织我的代码?
5 个解决方案
#1
6
If you want auto-formatting, look at SourceFormatX, which is a paid plug-in for Notepad++.
如果您想要自动格式化,请查看SourceFormatX,它是Notepad ++的付费插件。
Other than that, there are a few free plug-ins available on the Notepad++ Wiki which will format either HTML or PHP code.
除此之外,Notepad ++ Wiki上还有一些可用的插件可以格式化HTML或PHP代码。
#2
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.
通常的做法是为每个当前打开的“块”缩进一个级别。在PHP中,“块”只是{和}之间的代码。在HTML中,“块”是未在同一行上关闭的任何标记。
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.
在Notepad ++(以及许多其他代码编辑器)中,您可以选择几行代码并点击Tab以缩进整个选择(或Shift + Tab以使其突出)。这应该有助于保持代码整洁。
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.
另外需要注意的是,Notepad ++可以为您折叠块。在行号旁边,您应该看到一个带[ - ]框的树。您可以单击这些以折叠它们标记的块,以便更好地概览代码。
#3
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:
如果你需要一个插件来格式化你的HTML,你不清楚你是否只想要标签,但从常识来说,我想你正在寻找一个软件来重新编写代码。有一个插件Tidy2:
https://github.com/davegb3/NppTidy2
With this you can reformat all your HTML code, and change how to do it, which is often interesting.
有了这个,您可以重新格式化所有HTML代码,并更改如何操作,这通常很有趣。
#4
0
Select part of your code or any text and then press tab, it will indent all selected lines. Press shift + tab for unindent.
选择部分代码或任何文本,然后按Tab键,它将缩进所有选定的行。按shift + tab取消。
#5
-1
You can use the Tab button on your keyboard. Or you can go to Edit -> Indent -> Increase Line Indent.
您可以使用键盘上的Tab键。或者您可以转到编辑 - >缩进 - >增加行缩进。
Or was there something else you were talking about specifically?
或者你还有其他什么特别谈论?
#1
6
If you want auto-formatting, look at SourceFormatX, which is a paid plug-in for Notepad++.
如果您想要自动格式化,请查看SourceFormatX,它是Notepad ++的付费插件。
Other than that, there are a few free plug-ins available on the Notepad++ Wiki which will format either HTML or PHP code.
除此之外,Notepad ++ Wiki上还有一些可用的插件可以格式化HTML或PHP代码。
#2
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.
通常的做法是为每个当前打开的“块”缩进一个级别。在PHP中,“块”只是{和}之间的代码。在HTML中,“块”是未在同一行上关闭的任何标记。
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.
在Notepad ++(以及许多其他代码编辑器)中,您可以选择几行代码并点击Tab以缩进整个选择(或Shift + Tab以使其突出)。这应该有助于保持代码整洁。
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.
另外需要注意的是,Notepad ++可以为您折叠块。在行号旁边,您应该看到一个带[ - ]框的树。您可以单击这些以折叠它们标记的块,以便更好地概览代码。
#3
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:
如果你需要一个插件来格式化你的HTML,你不清楚你是否只想要标签,但从常识来说,我想你正在寻找一个软件来重新编写代码。有一个插件Tidy2:
https://github.com/davegb3/NppTidy2
With this you can reformat all your HTML code, and change how to do it, which is often interesting.
有了这个,您可以重新格式化所有HTML代码,并更改如何操作,这通常很有趣。
#4
0
Select part of your code or any text and then press tab, it will indent all selected lines. Press shift + tab for unindent.
选择部分代码或任何文本,然后按Tab键,它将缩进所有选定的行。按shift + tab取消。
#5
-1
You can use the Tab button on your keyboard. Or you can go to Edit -> Indent -> Increase Line Indent.
您可以使用键盘上的Tab键。或者您可以转到编辑 - >缩进 - >增加行缩进。
Or was there something else you were talking about specifically?
或者你还有其他什么特别谈论?