QA Graphic

How to Use the Reflow Document Feature in BBEdit

A Comprehensive Guide

BBEdit is a powerful text editor known for its flexibility and precision, particularly when working with HTML, XML, and other markup-heavy documents. Among its many features, the Reflow Document command stands out as a tool for improving document readability and structure by reformatting tags and content. Whether you're tidying up a single file or processing multiple files programmatically, this feature can save time and reduce errors.

In this blog post, you'll learn what the Reflow Document command is, the options it offers, and how to use it effectively in your workflow.


What Is the Reflow Document Command?

The Reflow Document command in BBEdit allows you to reformat the structure of an active document. It's particularly useful for improving the readability and maintainability of HTML, XML, and similar documents by adjusting indentation, wrapping text, and ensuring consistent formatting.

You can access this command in multiple ways:

  • Via the Markup menu. (Markup > Tidy > Reflow Document)
  • As part of a Text Factory action (for batch processing).
  • Through an AppleScript to process multiple documents programmatically.

Reflow Document

When invoked, BBEdit presents a configuration sheet where you can select from various formatting options tailored to your document's needs.


Reflow Document Options: A Breakdown

The configuration sheet includes several options, each designed to handle specific formatting tasks. Let's take a closer look at each:

1. Input is XML

If your document is XML rather than HTML, this option ensures that BBEdit uses the Tidy XML parser. Unlike the error-correcting HTML parser, the XML parser enforces stricter formatting rules, making it ideal for XML-based workflows.

2. Indent Block-Level Tags

This option determines whether block-level tags (such as <div>, <p>, or <section>) should be indented for better readability. Indented block-level tags can make it easier to understand the hierarchy and nesting of elements in your document.

3. Indent Attributes

When enabled, this option places each attribute on a new line. This is particularly useful for documents with complex tag attributes, as it improves clarity and simplifies attribute management during editing.

4. Wrap ASP Elements

This option wraps text contained within ASP pseudo-elements, which are denoted by <% ... %>. This is useful for developers working with ASP-based server-side scripting.

5. Wrap Attributes

With this option, BBEdit wraps long attribute values across multiple lines. This makes attributes easier to edit, especially when they contain lengthy data like URLs, inline styles, or embedded JSON.

6. Wrap JSTE Elements

This controls wrapping for text within JSTE pseudo-elements (<# ... #>), often used in templating systems. Wrapping ensures that the content is neatly formatted and easier to manage.

7. Wrap PHP Elements

If your document includes PHP code (e.g., <?php ... ?>), this option ensures that text within these pseudo-elements is wrapped appropriately, maintaining clarity and structure.

8. Wrap Script Literals

Script attributes containing long string literals (e.g., onclick="...") can be challenging to read. Enabling this option wraps these string literals, inserting a backslash () before line breaks for valid script syntax.

9. Wrap Sections

For documents containing CDATA or similar sections (<![ ... ]>), this option wraps the text inside these tags, making it easier to read and navigate through the content.


How to Use the Reflow Document Command

Here's a simple step-by-step guide to applying the Reflow Document command:

  1. Open the Document: Open the file you wish to reformat in BBEdit.
  2. Access the Command: Navigate to Markup > Tidy > Reflow Document.
  3. Configure the Options: Select the desired formatting options from the configuration sheet that appears.
  4. Apply Changes: Click OK to apply the reformatting to your document.

If you're working with multiple documents: - Use Text Factory to automate the process across multiple files.
- Alternatively, integrate the command into an AppleScript for custom workflows.


When to Use Reflow Document

The Reflow Document feature is best suited for scenarios where: - You need to clean up messy or inconsistent HTML or XML files.
- You're preparing code for collaborative development or deployment.
- You want to enforce formatting standards for a project.

For developers, this command ensures that your code is not only functional but also readable and maintainable?a critical aspect of efficient programming.


Wrapping Up

BBEdit's Reflow Document command is a versatile tool for streamlining the formatting of your markup documents. By leveraging its extensive configuration options, you can tailor the reformatting process to suit your needs, whether you're working with HTML, XML, or embedded scripting languages like PHP and ASP.

Start experimenting with the Reflow Document command today and see how it can enhance your coding workflow!

BBEdit is a powerful text editor known for its flexibility and precision, particularly when working with HTML, XML, and other markup-heavy documents. Among its many features, the Reflow Document command stands out as a tool for improving document readability and structure by reformatting tags and content. Whether you're tidying up a single file or processing multiple files programmatically, this feature can save time and reduce errors.

In this blog post, you'll learn what the Reflow Document command is, the options it offers, and how to use it effectively in your workflow.


What Is the Reflow Document Command?

The Reflow Document command in BBEdit allows you to reformat the structure of an active document. It's particularly useful for improving the readability and maintainability of HTML, XML, and similar documents by adjusting indentation, wrapping text, and ensuring consistent formatting.

You can access this command in multiple ways:

  • Via the Markup menu. (Markup > Tidy > Reflow Document)
  • As part of a Text Factory action (for batch processing).
  • Through an AppleScript to process multiple documents programmatically.

Reflow Document

When invoked, BBEdit presents a configuration sheet where you can select from various formatting options tailored to your document's needs.


Reflow Document Options: A Breakdown

The configuration sheet includes several options, each designed to handle specific formatting tasks. Let's take a closer look at each:

1. Input is XML

If your document is XML rather than HTML, this option ensures that BBEdit uses the Tidy XML parser. Unlike the error-correcting HTML parser, the XML parser enforces stricter formatting rules, making it ideal for XML-based workflows.

2. Indent Block-Level Tags

This option determines whether block-level tags (such as

,

, or

) should be indented for better readability. Indented block-level tags can make it easier to understand the hierarchy and nesting of elements in your document.

3. Indent Attributes

When enabled, this option places each attribute on a new line. This is particularly useful for documents with complex tag attributes, as it improves clarity and simplifies attribute management during editing.

4. Wrap ASP Elements

This option wraps text contained within ASP pseudo-elements, which are denoted by <% ... %>. This is useful for developers working with ASP-based server-side scripting.

5. Wrap Attributes

With this option, BBEdit wraps long attribute values across multiple lines. This makes attributes easier to edit, especially when they contain lengthy data like URLs, inline styles, or embedded JSON.

6. Wrap JSTE Elements

This controls wrapping for text within JSTE pseudo-elements (<# ... #>), often used in templating systems. Wrapping ensures that the content is neatly formatted and easier to manage.

7. Wrap PHP Elements

If your document includes PHP code (e.g., ), this option ensures that text within these pseudo-elements is wrapped appropriately, maintaining clarity and structure.

8. Wrap Script Literals

Script attributes containing long string literals (e.g., onclick="...") can be challenging to read. Enabling this option wraps these string literals, inserting a backslash () before line breaks for valid script syntax.

9. Wrap Sections

For documents containing CDATA or similar sections (), this option wraps the text inside these tags, making it easier to read and navigate through the content.


How to Use the Reflow Document Command

Here's a simple step-by-step guide to applying the Reflow Document command:

  1. Open the Document: Open the file you wish to reformat in BBEdit.
  2. Access the Command: Navigate to Markup > Tidy > Reflow Document.
  3. Configure the Options: Select the desired formatting options from the configuration sheet that appears.
  4. Apply Changes: Click OK to apply the reformatting to your document.

If you're working with multiple documents: - Use Text Factory to automate the process across multiple files.
- Alternatively, integrate the command into an AppleScript for custom workflows.


When to Use Reflow Document

The Reflow Document feature is best suited for scenarios where: - You need to clean up messy or inconsistent HTML or XML files.
- You're preparing code for collaborative development or deployment.
- You want to enforce formatting standards for a project.

For developers, this command ensures that your code is not only functional but also readable and maintainable?a critical aspect of efficient programming.


Wrapping Up

BBEdit's Reflow Document command is a versatile tool for streamlining the formatting of your markup documents. By leveraging its extensive configuration options, you can tailor the reformatting process to suit your needs, whether you're working with HTML, XML, or embedded scripting languages like PHP and ASP.

Start experimenting with the Reflow Document command today and see how it can enhance your coding workflow!

 

About

Welcome to the BBEdit Blog, the official source of insights, tips, tricks, and inspiration for all users of BBEdit, the powerful text and code editor from Bare Bones Software. Whether you're a seasoned developer, a budding coder, or someone who just loves the precision of text editing, this blog is crafted for you.

Interested in getting BBEdit? Get it from Bare Bones' Website.

Schedule

TuesdayQA
WednesdayAffinity
ThursdayBBEdit
FridayMacintosh
SaturdayInternet Tools
SundayOpen Topic
MondayMedia Monday