Sangrar correctamente el código con Notepad++

Sangrar correctamente el código con Notepad++

¿Puede Notepad++ sangrar correctamente el código?

Si tuviera esto:

<div><div><div></div></div>   </div>

¿Hay alguna manera de convertirlo en lo siguiente?

<div>
  <div>
    <div>
    </div>
  </div>
</div>

Respuesta1

Puede utilizar el complemento TextFX para reindentar el código por usted. Si no lo tiene, deberá instalarlo desde su administrador de complementos. Una vez en su lugar > simplemente use el menú "TextFX" > "Editar TextFX" > "Reindentar código C++".

Probablemente no convierta ni una sola línea, pero el código real con sangrías erróneas se manejará bien.

Encontrarás más información y otros complementos explicados.aquí.

Respuesta2

InstalarSangría por pliegueenchufar. Funciona bien con etiquetas XML (o derivadas).

Respuesta3

Todo mi código estaba en una sola línea (minificado). Lo que hice fue usar un "desminificador" en línea para dividir el código en varias líneas. Hay muchos disponibles sibusca en Google, pero aquí está el que funcionó mejor para mí: http://mrcoles.com/blog/css-unminify/

Entonces utilicé el complemento.@Magnum mencionado(TextoFX) para adornar aún más las sangrías en el código. ¡El resultado fue genial!

Antes:

object(stdClass)#2 (1) { ["GetDocTypeListResult"]=> object(stdClass)#3 (1) { ["DocType"]=> array(14) { [0]=> object(stdClass)#4 (2) { ["id"]=> string(3) "180" ["name"]=> string(49) "Return Merchandise Authorization and Notification" } [1]=> object(stdClass)#5 (2) { ["id"]=> string(3) "810" ["name"]=> string(16) "Customer Invoice" } [2]=> object(stdClass)#6 (2) { ["id"]=> string(3) "816" ["name"]=> string(28) "Organizational Relationships" } [3]=> object(stdClass)#7 (2) { ["id"]=> string(3) "820" ["name"]=> string(31) "Payment Order Remittance Advice" } [4]=> object(stdClass)#8 (2) { ["id"]=> string(3) "824" ["name"]=> string(18) "Application Advice" } [5]=> object(stdClass)#9 (2) { ["id"]=> string(3) "830" ["name"]=> string(41) "Planning Schedule with Release Capability" } [6]=> object(stdClass)#10 (2) { ["id"]=> string(3) "840" ["name"]=> string(21) "Request for Quotation" } [7]=> object(stdClass)#11 (2) { ["id"]=> string(3) "846" ["name"]=> string(24) "Inventory Inquiry/Advice" } [8]=> object(stdClass)#12 (2) { ["id"]=> string(3) "850" ["name"]=> string(14) "Purchase Order" } [9]=> object(stdClass)#13 (2) { ["id"]=> string(3) "852" ["name"]=> string(21) "Product Activity Data" } [10]=> object(stdClass)#14 (2) { ["id"]=> string(3) "860" ["name"]=> string(47) "Purchase Order Change Request - Buyer Initiated" } [11]=> object(stdClass)#15 (2) { ["id"]=> string(3) "864" ["name"]=> string(12) "Text Message" } [12]=> object(stdClass)#16 (2) { ["id"]=> string(3) "945" ["name"]=> string(25) "Warehouse Shipping Advice" } [13]=> object(stdClass)#17 (2) { ["id"]=> string(3) "997" ["name"]=> string(26) "Functional Acknowledgement" } } } }

Después:

object(stdClass)#2 (1)  {
    ["GetDocTypeListResult"]=> object(stdClass)#3 (1)  {
        ["DocType"]=> array(14)  {
            [0]=> object(stdClass)#4 (2)  {
                ["id"]=> string(3) "180" 
                ["name"]=> string(49) "Return Merchandise Authorization and Notification" }
            [1]=> object(stdClass)#5 (2)  {
                ["id"]=> string(3) "810" 
                ["name"]=> string(16) "Customer Invoice" }
            [2]=> object(stdClass)#6 (2)  {
                ["id"]=> string(3) "816" 
                ["name"]=> string(28) "Organizational Relationships" }
            [3]=> object(stdClass)#7 (2)  {
                ["id"]=> string(3) "820" 
                ["name"]=> string(31) "Payment Order Remittance Advice" }
            [4]=> object(stdClass)#8 (2)  {
                ["id"]=> string(3) "824" 
                ["name"]=> string(18) "Application Advice" }
            [5]=> object(stdClass)#9 (2)  {
                ["id"]=> string(3) "830" 
                ["name"]=> string(41) "Planning Schedule with Release Capability" }
            [6]=> object(stdClass)#10 (2)  {
                ["id"]=> string(3) "840" 
                ["name"]=> string(21) "Request for Quotation" }
            [7]=> object(stdClass)#11 (2)  {
                ["id"]=> string(3) "846" 
                ["name"]=> string(24) "Inventory Inquiry/Advice" }
            [8]=> object(stdClass)#12 (2)  {
                ["id"]=> string(3) "850" 
                ["name"]=> string(14) "Purchase Order" }
            [9]=> object(stdClass)#13 (2)  {
                ["id"]=> string(3) "852" 
                ["name"]=> string(21) "Product Activity Data" }
            [10]=> object(stdClass)#14 (2)  {
                ["id"]=> string(3) "860" 
                ["name"]=> string(47) "Purchase Order Change Request - Buyer Initiated" }
            [11]=> object(stdClass)#15 (2)  {
                ["id"]=> string(3) "864" 
                ["name"]=> string(12) "Text Message" }
            [12]=> object(stdClass)#16 (2)  {
                ["id"]=> string(3) "945" 
                ["name"]=> string(25) "Warehouse Shipping Advice" }
            [13]=> object(stdClass)#17 (2)  {
                ["id"]=> string(3) "997" 
                ["name"]=> string(26) "Functional Acknowledgement" }
        }
    }
}

Respuesta4

Elordenado2El complemento hace exactamente lo que quieres.

información relacionada