yamlfmt version
yamlfmt 0.20.0 (Homebrew)
Is your feature request related to a problem? Please describe.
Yes. Currently yamlfmt always normalizes the spacing before line comments according to the pad_line_comments setting.
When developers manually align comments in columns (a very common practice in configuration files, Ansible roles, Kubernetes manifests, documentation-style YAML, etc.), this alignment is completely destroyed.
Example:
# Before formatting (nicely aligned at column 50)
database_host: 127.0.0.1 # primary server
database_port: 5432 # default port
cache_enabled: true # enable caching
debug_mode: false # disabled in production
# After yamlfmt – alignment is lost
database_host: 127.0.0.1 # primary server
database_port: 5432 # default port
cache_enabled: true # enable caching
debug_mode: false # disabled in production
Even setting pad_line_comments to a high value does not preserve large manual indents – the formatter still collapses them.
Describe the solution you’d like
Add a new boolean option in the basic formatter:
preserve_comment_indents: true|false # default: false
When true: Indentation before # in line comments is preserved exactly as in the original file.
yamlfmt version
Is your feature request related to a problem? Please describe.
Yes. Currently
yamlfmtalways normalizes the spacing before line comments according to thepad_line_commentssetting.When developers manually align comments in columns (a very common practice in configuration files, Ansible roles, Kubernetes manifests, documentation-style YAML, etc.), this alignment is completely destroyed.
Example:
Even setting
pad_line_commentsto a high value does not preserve large manual indents – the formatter still collapses them.Describe the solution you’d like
Add a new boolean option in the
basicformatter:When
true: Indentation before#in line comments is preserved exactly as in the original file.