In English, we use the verb form ending in -ing quite often without distinguishing between the use cases. This makes it difficult when we switch to Spanish, since we now must make that distinction.
In Spanish, we have to distinguish between using el gerundio and el infinitive, the gerund and the infinitive forms. Fortunately, there are a few simple tricks I will show you to determine if you are dealing with the infinitive, and if not, then use the gerund.
The gerund has three uses:
Progressive. Use the gerund with the verb estar to denote a continuing action, such as estoy leyendo, or "I am reading." Note that Spanish-learners tend to over-use the progressive tense (as in, they use it more than a native would). You really want to reserve this for when it is important that the action is in progress (or was in progress if using the past continuous tenses).
Adverb. Is your word, e.g., "walking", "talking", "laughing", describing how an action is being done? If so, then its an adverb, and you use the gerund. Pasamos el día riendo. "We spend the day laughing." How did we spend the day? Laughing. Adverb.
Continuous action. Similar to the first case, here we use the gerund with one of a few particular verbs, andar, ir, seguir, and venir, to express ongoing action. Seguí estudiando. → "I kept on studying."
There are two main cases when you would want to use the infinitive and not the gerund.
Noun. If the word is a noun in the sentence, then use the infinitive. Here is the pro-top:
If you can replace the -ing form in English with the infinitive "to +
Adjective. Rather than an adverb, if the word is describing a noun, it is an adjective and you want to use the infinitive. For example, "reading group" is NOT "el grupo leyendo", but rather "el grupo de leer". The tip here is if the word comes after a preposition, or could come after a preposition (like de + ...), then use the infinitive. "We will leave after eating", "Vamos a salir después de comer."
Fortunately, that's pretty much it, and with these two simple rules you can figure out when to use an infinitive in the confusing cases, everything else is a gerund.