from the notes
Generally speaking, a gerund is the ~ing form of a verb, a verbal noun. Korean has two ways of forming what would be a gerund in English, with overlapping but slightly different uses.
The most popular form is the present tense modifier (V는) plus 것. This form is the more common in speaking. 하는 것 has a connotation of an ongoing action, not just "doing" but "the act of doing." Just like in other circumstances, 것 can be abbreviated or contracted to 거, 건, 게, 걸.
The second form is made by taking the verb stem (V) plus 기. This form may sometimes be more formal. 하기 has a more general connotation, "doing," and may be more abstract or impersonal. To say "before doing X" we use this form, saying X하기 전에.