If the paint is still wet, I scratch a line in it with a painting knife or the handle of a brush. If the paint has dried, I either mark it just with a damp brush (if I'm using acrylics) or with a very thin bit of paint so it doesn't impact on what I'm subsequently going to paint.
It's something that'll work wherever you need a straight line, whether horizontal or vertical. Look for a T-Square that's long enough to extend across most the width of the typical size canvas you use. If you don't have very strong hands, look for a lightweight plastic one.
I use an old wooden one of my Dad's, which is very sturdy. (It has one straight edge and one angled, which I've made idiot-proof by painting the large arrow on it pointing to the straight edge!) I don't stress about getting paint on it (it is just a working tool after all), but at the same time do make a point of wiping the edge after I've used it so it doesn't become uneven from accumulated dried paint.
Buy Direct: Buy Wooden T-Square and Plastic T-Square
Knife Painting Tutorial: Rocky Seascape