There's a rule for when to use の and when to use こと for the nominalization of a verb, but I don't remember it properly.
This paper claims two things: (1) の is used for spatio-temporal clause nominalization (泳ぐの) and こと is used for non-spatio-temporal clause nominalization (であること) and (2) の is used when the speaker things the clause is in the addressee's consciousness while こと is not.
The first is what I was taught (upon review), but the second description raises some interesting points. Read the paper to learn some interesting things about fine distinctions between the two.