Configuration file guides

Format a Route INI File and Keep Its Literal Values

·

A readable config diff should show the layout changes you meant to make. Keep comments and values in source order so a reviewer can distinguish formatting from an actual setting change.

INI Formatter

Format the route sample in Literal INI

Load the example and select Format INI. Profile is a global key. The words and two spaces on either side of Café stay inside the quotes. In the north section, Enabled retains its colon separator with a space on each side.

The Route value still contains ${Profile}/0012 ; keep this. In this literal dialect the apparent interpolation and the semicolon suffix are part of the string. Behavior differs in consumers with interpolation or inline comments enabled.

Python ConfigParser, supported structure and optionsPHP INI parser modes and syntax differences

Remove the two optional section gaps

With Add blank line before sections selected, the sample gains one gap before north and one before south. Clear the option and format again to keep the original section spacing. The full-line opening comment remains in both results.

Existing line endings stay on their original retained lines. A new gap uses the preceding line’s ending. Open a UTF-8 file directly when it has a BOM or mixed line endings you need to preserve.

Python ConfigParser, supported structure and optionsFreedesktop Desktop Entry Specification, whitespace and comments

Check the strings and separators before replacing the file

Download formatted.ini and reopen it as text. Check that the opening comment, both sections, the global profile and the original section order are present.

The formatter compares parsed values before and after rewriting. Also read the result with your destination parser. Use ConfigParser-style raw INI when indentation defines a multiline value.

Python ConfigParser, supported structure and optionsPHP INI parser modes and syntax differences

Common questions

Will the formatter reorder the sections alphabetically?

It keeps the original section and key order.

Which text counts as a full-line comment?

The first nonspace character must be a semicolon or hash. Inline punctuation remains part of the value.

Sources

Put it into practice.

Related guides