using direct object pronouns
How do you know when to the direct object pronoun goes in front of the verb, i. e. Lo da, or attach it to the end of the verb i.e. verla.
Both direct- and indirect-object pronouns are typically placed before conjugated verbs. They can be (but don't have to be) attached to infinitives and present participles: Te voy a escribir una carta and voy a escribirte una carta (I am going to write a you a letter) are both correct, as are le estoy comprando un coche and estoy comprándole un coche (I am buying him a car).
In commands, direct and/or indirect objects are attached to affirmative commands but precede negative commands. Escríbeme (write me), but no me escribas (don't write me).
Note that in affirmative commands and when attaching an object to a present participle, attaching the object at the end of the verb can result in an accent being needed to keep the stress on the correct syllable.
If you have a direct object and an indirect object with the same verb, the indirect object comes first. Te las escribo. (I am writing them to you.)