Skip to content

Format your code

Question

Have you ever looked at someone else's code and found it hard to read because they formatted it differently to your code?

Using a consistent code style can help make your code more legible and accessible to others, in much the same way that standard use of punctuation and spacing makes written text easier to read.

Tip

Good coding style is like using correct punctuation: you can manage without it, butitsuremakesthingseasiertoread.

— Hadley Wickham, the tidyverse style guide

We strongly recommend using an editor that can automatically format your code whenever you save. This allows you to completely forget about formatting and focus on the content.

We list here some of the most commonly used style guides and code formatters:

Language Style guide(s) Formatter
R tidyverse styler
Python PEP 8 and The Hitchhiker's Style Guide black
Julia style guide Lint.jl