The answer mentioned above is correct but there is also a shortcut built in which is math autocorrect. It is much like LaTeX. By default it's inactive but you can activate it and is really helpful if you want to write big equations. For example, if you want to type $$\ce{H2}$$H then you just have to type H_2.