Shimmies
Sometimes a fish will normally appear to just be swimming or hovering in fish inside of the water column, however when they shake back and forth either in space or against an object something is wrong. This symptom is called shimmies and normally is not the only symptom that a fish may be representing when this is present. Shimmies are mostly associated with livebearers as it is highly common in them when the water conditions are not ideal for their specific liking, although it can be present in all other types of fish. Since this is not a disease but rather a symptom of various diseases, there isn't a direct or clear treatment that can be applied to cure/prevent the symptom.
Identification
The most obvious sign will be that the fish is rocking back and forth rapidly in place or while swimming around (it appears to be swimming harder than normal and is going less a distance than before). Other smaller signs include the fish twitching, vibrating in place, and in some cases, the fish will become highly aggressive against its tank mates (or those who come near it). Shimmies are most notable when the fish is having reproductive behaviors (for example a male trying to mate with a female, a female about to give birth, etc.) and make this rather easy to spot compared to other diseases.
Pathology
The most common traits that will make a fish have the shimmies can include it being a symptom of another disease or an indication that the environment does not suit the fish's natural water parameter acceptable range. In an extremely vast majority of cases where a fish had this symptom, the reason was due to an environmental factor that wasn't accounted for. Such environmental factors can include a fish that is suffering from ammonia poisoning, nitrite poisoning, pH is not stable (or it can be too high or low and the fish cannot adjust quickly enough), and lastly, if the water temperature is too cold. A variety of diseases can induce the shimmies into a fish including but not limited to fin rot, certain bacterial and protozoan diseases, poisoning either from overdosing on medications or fertilizers, and in some cases an overabundance of metallic traces inside of the water column.
Many will notice that livebearers tend to have the shimmies more than any other type of fish, and this is because they do not do well in water conditions that are outside of their acceptable range and may take a few generations to get used to the abnormal water conditions.
Treatment and Medication
Since this is not a specific disease or infection but a symptom of many, making sure that the water quality is perfect should be the main concern. In many cases having bad water quality, many fish will start this behavior to alert their owners that something is wrong. The first step would be to check the water parameters and make sure that all of the levels are in the acceptable range for your fish species. If you notice that a level is either too low or too high for the fish's acceptable range, try to do a water change and see if that helps. If it does not, raising the temperature a few degrees higher can have a positive effect and reduce (or fully remove) the shimmies that it may have. If you notice that the water temperature is too cold for a given species of fish that you are keeping, make sure to raise it slowly throughout the day like a sudden increase in temperature can do more damage than good.