When you hear the first sniper bullet fired, prepare to do a quick direction finding. Move from left to right, while moving in the general direction of the sniper. Using headphones will help dramatically for this. As the sniper fires each additional shot, you will be able to zero in on the location from the sound volume in left/right speakers. Once the sound is equal, the sniper is straight ahead. Distance finding is by the crack/thump method. A bullet is travelling at greater than the speed of sound, so the sound wave of the rifle will follow the crack of the bullet passing by. The difference between when you hear the bullet pass by (crack), and when you hear the firing from rifle (thump) will tell you the distance. If the crack and thump are close the sniper is 300 yards or closer. If there is a slight delay, the sniper is from 300-600 yards. If there is a noticeable delay, the sniper is out past 600 yards. This is where good gaming code will make a difference. If the game is not designed well, this method will not work reliably.
A sniper is most easily spotted during movement. The top of a ridgeline is the most obvious place to spot someone moving. If the sniper moves often, you can scan the area and spot him.
Knowing the maps you are playing on very well will help you spot a sniper at long ranges. After a while of playing a map, you start to recognize all of the patterns and spots. A sniper at long range will only be a few pixels, but that will be a few pixels out of place. Learn to look for the smallest amount of changes in the maps.
Learning the favorite spots of snipers can be pretty easy. People are predictable, and some snipers will continually go to the same spots. When a sniper is on your team, look at the maps and see where he moves, and where he moves to. The next time you play, and that same sniper is on the other team, you will know his most likely routine. Some snipers will recognize this, and will take different routes if they see you as an opponent, so make sure to know their most likely alternate routes too.