It’s mostly a question of convention as to which form you use when. I’m still getting to grips with grammar here so anyone who knows better is free to jump in and correct me.
泳ぎ is a special form of the word 泳ぐ - specifically the
連用形 form. Japanese uses 連用形 to make polite verbs (ending in ~ます, ~ません, ~ました, etc) - 連用形 is often called the -masu form or stem form. It’s also used to make the honorific/humble 敬語 forms of verbs.
- 泳ぎます = I swim, you swim, he swims (polite)
- お泳ぎになります = You/they swim, he/she swims (honorific)
- お泳ぎします = I swim (humble)
連用形 is used to create compounds too!
- 泳ぎ始める = (gradually) start swimming
- 泳ぎだす = suddenly start swimming (with the implication of uncontrolledness)
- 泳ぎ終わる = finish swimming
- 食べやすい = easy to eat
- 食べにくい = hard to eat
- 食べやがる = eat to the dismay and offense of the speaker (やがる also takes て form)
The 連用形 form is also used as a conjunctive form in places like newspaper headlines for brevity’s sake. In everyday speech/writing, you’d use V-て form for this.
連用形 is also a stand-alone noun form for some verbs, like 終わり, or お替わり which means “(honourable prefix)-replacement” but in practice means something like “another drink please” once you’ve finished your cafe mocha. (Penguin in しろくまカフェ says this a lot.) The thing is that by convention not every verb has a 連用形 noun (according to this page) so you’d have to specifically learn which do and which don’t.
泳ぐこと… (or 泳ぐの…) is a grammatical structure which turns verbs and sentences into noun phrases. Unlike the 連用形 noun form, you can use this with any verb or sentence you like - although the sentence has to use plain verbs and can’t have a は particle - が is fine.
What’s a noun phrase? Think of it as a word or words which can function the way a noun does in a sentence, identifying a thing or things. For example:
- dogs
- the dog
- a big dog
- that big smelly brown dog with mange and fleas that always barked at me when I went past its house in the morning on my way to that job where I had to paint pupils on the eyes of small wooden dolls
All of the above are noun phrases because they identify a thing. That last one is long but it’s still identifying a thing or things (in a very rambly way). And so we can use grammar to talk about swimming, forgetting and even watching Polar Bear Cafe.
- 泳いだ = I swam (past plain form of 泳ぐ).
- 泳いだことがあります = I’ve been swimming before.
- コテスローに泳いだことがあります = I’ve been swimming at Cottesloe before.
- 宿題を忘れた = I forgot my homework
- 宿題を忘れたことがありません = I’ve never forgotten my homework.
- 友達としろくまカフェを見ている = (I am) watching Polar Bear Cafe with friends.
- 友達としろくまカフェを見ているのは楽しみます = It’s fun watching Polar Bear Cafe with friends.
According to the Dictionary of Basic Japanese Grammar (p320), の is used more for concrete and perceptible events with the implication of emotional closeness (swimming is something you can watch), while こと is for abstract and imperceptible events with the implication of emotional distance. That said, there’s particular phrases which demand the use of こと instead of の and vice versa, e.g for AはBだ (or Bです) you have to use こと (DBJG p319).
Here’s some examples:
- 泳ぐことがありません = I’ve never been swimming before.
- 泳ぐことが嫌いですよ = I hate swimming.
- 泳ぐことができますか = Are you able to swim?
- 静江が泳ぐのをみていた = (I) was watching my friend Shizue swim (DBJG p195, needs の because it’s directly perceived)
Because 泳ぐ has a 連用形 stand-alone noun form, you can say this…
- 泳ぎが嫌いだよ = I hate swimming.
… but I don’t know if it would sound natural or literary or not.
Hope that helps!