#4198·buf

format comments with consistent spacing

Author: macmoritzCreated Dec 1, 2025Updated Jun 25, 2026
LabelsFeature

Feature

Normally comments are started by a prefix, in protobuf it is //, followed by a space and the content.
Sadly buf format does not fixes missing or multiple spaces.
Sadly the space is not defined by the language guide but I think it is best practice to add a space. Therefor I am fine with an optional argument or config option.

Example

proto
syntax = "proto3";

package test.v1;

//no space (incorrect)
// one space (correct)
//   multiple spaces (incorrect)
message TestMessage {}

Expected

Expected after buf format file.proto:

proto
syntax = "proto3";

package test.v1;

// no space (incorrect)
// one space (correct)
// multiple spaces (incorrect)
message TestMessage {}

Any thoughts are welcome!