How do you snap lines to a grid?
Snapping can be activated using the little magnet icon.  Next to this is a menu for setting the snap type.  What you can't see in the image is that after I activated the tool, I pressed g to move the object and then x to constrain the movement to the x-axis. 



If you have the menu set to Increment as shown above, then you can also disable the magnet icon and hold down Ctrl to use the snapping feature.  

Conversely, if you do still have the magnet icon activated, holding Ctrl will disable snapping so long as Ctrl is held.

Holding Shift will allow you to move the object in smaller increments.  This is true with or without snapping enabled.

I feel I should mention that snapping can also snap the vertices of one object to  another object by changing the menu selection to Face.  Even though it's unrelated to what you mention, I wanted to point out that the tool has more functionality than just for what you asked here since it's also very useful for re-topology, aligning model components to one another, etc...