Do not use any indentation styles other than K&R, Allman, and their mix, which uses K&R [for|with] control flow statements and Allman [for|with] function definitions.

// K&R         // Allman     // A mix of K&R and Allman
if (...) {     if (...)      function()
    ...        {             {
} else {           ...           if (...) {
    ...        }                     ...
}              else              } else {
               {                     ...
                   ...           }
               }             }

I don't understand whether I should use for or with in sentences like the one above.

(Surprisingly, there are no related articles or forum threads on the Internet.) Could you explain it to me?

  • 1
    Both prepositions for, with are fine, as also would be in, and possibly others. There's no real need for online forums to spend a lot of time discussing such things, because the meaning is obvious regardless, and the primary purpose of such technical documentation is to communicate, not to showcase writing skills. Oct 19, 2020 at 11:54
  • @FumbleFingersReinstateMonica Do you have any personal preference?
    – john c. j.
    Oct 19, 2020 at 12:17
  • 1
    To be honest, I'd probably mostly tend to use in myself anyway. But (outside the context of answering your question here) I wouldn't give it much thought. And if I had to write the same thing several times over, sufficiently far apart that I didn't remember which preposition I'd used last time, I'm sure that I'd use at least all those three (and perhaps others) from time to time. Oct 19, 2020 at 12:27

1 Answer 1


This is somewhat a matter of opinion and style. Prepositions can often be used interchangeably in English.

"For" is a more direct and unambiguous preposition to use in the example. You use a tool (or a type of indent formatting) for something -- for this type of code to be formatted correctly.

You may also use a tool "with" something, but that shifts the meaning somewhat from a description of purpose to a description of connection.

To summarize the question shows that "for" and "with" are both understandable:

Which indent should be used for different types of code statements?

Which indent should be used with different types of code statements?

You can think of "for" and "with" actually standing for these longer phrases:

For -- "for the purpose of" formatting this code correctly.

With -- "in connection with" this code's correct formatting.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .