Wednesday, July 23, 2025

Re: program to indent C code?

Paul Wisehart <paul@oldcode.org> wrote:
> Hi!,
>
> I have been learning to program in C on OpenBSD
> and it is super great. I love that you can
> just use builtin stuff to write code, like
> the man pages are great.
>
> My issue is that I have grown to like code
> formatters after using them in golang and then
> python. I use the builtin 'indent' which is
> great, BUT it chokes on more cryptic stuff like
> nested parens, and array literals.
>
> Do other OpenBSD C programmers use code formatters?
> What do they use?
> Should I just be more comfortable formatting my code
> as I type?

I tried a bit clang-format since I wanted to experiment with LSP too but
it's not for me. While I'm happily using `gofmt' on save for Go, i
haven't found something that pleases me enough for C. (also because on
Go I gave up at indenting as i wanted, on C not yet)

mg in base does a pretty good job out-of-the-box at indending C as you
type. emacs can also be tought to follow style(9), except for some
nits, quite easily too.

p.s. there's knfmt by anton@ too, but I haven't used it extensively yet
to comment on it.

No comments:

Post a Comment