How do you indent your code?

I’ve been reading the Coding Conventions of RIOT and I’m wondering how do you manage to stick to them? Do you just code like that or do you have a tool to auto indent?

Now I’m using Visual Studio Code and the Ctrl + Alt + L (auto indent) has a completely different style. What editor/tool are you using? Is there any preset that I can load and use or do I need to set up everyting manually?

Regards.

We’re using uncrustify. There’s a RIOT config for it at https://github.com/RIOT-OS/RIOT/blob/master/uncrustify-riot.cfg.

1 Like

Thank you! It is exactly what I was looking for!

Like Kaspar said, there’s uncrustify to check if your code follows the predefined code-style, but to be honest I don’t think using uncrustify for anything else than a final check before pushing is a good idea.

Most tools allow you to configure stuff like indentation in a config file. (e.g. for Vim it’s in the .vimrc where you add set expandtab and set softtabstop=4 for 4 spaces for each tab). I guess VSCode also has these settings somewhere?

Let me disagree with you. I absolutely see no point in using VSCode formatting or changing it, It´s a waste of time. I already set up uncrustify + uncrustify VSCode extension. I placed the already existing uncrustify config file in the RIOT root directory and when I press the standard VSCode format button the code is automagically formatted according to the code style. And this is only for this project. This is awesome, I can use other indents in other projects and I don´t need to mess with the settings. Everything is done for me and I can bee 100% sure that my indentation is correct. It took me about 10minutes to set up everything.