Home:ALL Converter>Restrict VSCode C formatting to a minimum

Restrict VSCode C formatting to a minimum

Ask Time:2022-12-12T03:15:13         Author:ygoe

Json Formatter

VSCode is a decent code editor, but it appears to me that I can only have it in two ways: 1. Super-aggressive in formatting my code, or 2. completely dumb and unaware of how code looks like.

When editing C code for my microcontroller project with PlatformIO, it keeps moving things around that I just wonder what's going on. Comments are aligned (didn't ask for it), additional empty lines are removed (I'll do that when I'm finished here), the next line is pulled to the end of the current line sometimes, entire pages of following code are indented when I paste code that doesn't end with a semicolon (what was it even thinking?!). I'm starting to get used to pressing Ctrl+Z after pasting text or pressing Enter and at other times.

With format on type/paste disabled, I won't even get the line after an if statement indented after pressing the Enter key if I'm not using {}. I could just use Windows Notepad instead. Or Notepad++ which has none of the advanced code formatting but works really well for all C-like languages in general.

VSCode isn't all that annoying with JavaScript code. Can't remember how it went with other languages (PHP, Python, HTML). I did find a ton of settings about C code formatting but either the required ones are missing or I can't find them, or they have no effect. I have the impression that VSCode developers have very strong coding style guidelines and never deviate from them, and they also have a complicated or unknown editing style which I've never seen or used. I'm just typing down code without any auto-completions. Of course this will lead to invalid and incomplete code until just before finishing the line. If the editor can't handle that, it better shouldn't mess with it.

What do I have to do to make VSCode behave more like Notepad++ for C code, without using Notepad++?

(I wouldn't have thought of Stack Overflow for asking this, but it seems like that's the place recommended by VSCode. I couldn't find another forum-like community for it. Their GitHub discussions are restricted to extension development.)

Author:ygoe,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/74763731/restrict-vscode-c-formatting-to-a-minimum
yy