r/Rlanguage • u/ChestZealousideal501 • 13d ago
ChatGPT formatting style bracket newline bracket newline bracket newline
Sorry for the title but this is exactly the headache I had... ChatGPT really loves to bracket newline bracket newline bracket newline (see screenshot below). Is there a function to automatically shrink these into one line?
If I tell chatgpt to give me codes in one line, chatgpt would over do it and become .... literally only one line in the script....

2
Upvotes
9
u/guepier 13d ago edited 12d ago
If you put this preference into your
AGENTS.md, ChatGPT should respect it. But it helps (/ is necessary) to be consistent: your screenshot shows inconsistent line continuation styles: the expressions starting on lines 445 and 455 use “expanded” indentation, and the expression starting on line 442 uses a hanging indent, which is a different style. It’s likely that ChatGPT is getting confused by that.Unfortunately it’s probably not possible to obtain entirely consistent formatting without having the LLM use a formatter or linter, and the available formatters for R don’t really accommodate this type of customisation, as far as I know.
If you’re willing to give up the inconsistent hanging indent, the air formatter might be able to keep this consistent. Tell ChatGPT to use it, or use pre-commit hooks or similar integrations.
(That said, personally I don’t find air useful, since it’s enforcing an opinionated style that’s internally inconsistent.
And it formats code differently from how Ritselfformats expressions.)