There really are no shortcuts for this one. You need to practice writing chemical equations by answering practice tests.
Usually textbook problems have an answer key at the back to help you check your answers.
For ionic bonding, which what usually happens when a non-metal bonds with a metal, the chemical equation is simple. All you need to do is to "exchange the superscripts for subscripts". Take a look at the example below:
For covalent bonds, which is usually a bond between non-metals, it is a little trickier since you have to make sure that the bonds follow the octet rule (eight valence electrons per element). For example, the bonds with C and H can be as drawn and written as follows (with every line representing 2 electrons shared between the elements),