Substituting a Gerund for an Infinitive

Both the gerund and the infinitive are verbal nouns. In many cases it is possible to substitute a gerund for an infinitive.

Read the sentences given below:

Seeing is believing. OR To see is to believe.
Cooking is an art. OR To cook is an art.
Can you teach me painting? OR Can you teach me to paint?
To work is better than to worship. OR Working is better than worshipping.

In some cases both gerund and infinitive can be used but with a different shade of meaning.

Compare:

You must remember writing to her. (Here the gerund indicates that the act of writing happened in the past.)
You must remember to write to her. (Here the infinitive indicates that the act of writing is yet to take place in future.)
I like singing. (General statement)
I like to sing this particular song. (More definite statement)

Cases where only gerund can be used

Only a preposition + gerund can be used after certain verbs and adjectives. Examples are: think, desirous, despair, fond, confident, interested, prevent, abstain, refrain, prohibit, good, object etc.

I am thinking of writing an autobiography. (NOT I am thinking to write a biography.)
We are confident of winning. (NOT We are confident to win.)
She is good at painting. (NOT She is good to paint.)
She insisted on coming with me. (NOT She insisted to come with me.)
You must refrain from talking to such people. (NOT You must refrain to talk to such people.)

Only a gerund can be used after a possessive.

She hates my coming late at night. (NOT She hates my to come late at night.)
I don’t mind your joining the other party.
She insisted on my joining them.
She objected to John’s entering her room.

Note that this rule is not strictly followed now especially in the case of Proper nouns. So the sentence She objected to John entering her room is now considered correct.

Note that we do not use a possessive case with the gerund when the noun denotes a lifeless thing.

There is no danger of the roof crashing. (NOT There is no danger of the roof’s crashing.)

Gerund and Present Participle

Both gerund and present participle end in –ing. But gerund functions like a noun and present participle functions like an adjective.

A rolling stone gathers no moss. (Here the participle rolling is used as an adjective modifying the noun stone.)
I like swimming. (Here the gerund swimming is used as the object (noun) of the verb like.)