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. Since this is not a disease but rather a symptom of various diseases, there isn't a direct or clear treatment.
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 of a distance than before). There are other smaller signs that 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 is 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 makes this rather easy to spot compared to other diseases.
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 suite 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 due to the fact that 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 either 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 as a sudden increase in temperature can do more damage than good.
Due to the way that this symptom effects the inhabitants, the best prevention methods are to always make sure that you quarantine anything that you place inside of your water (this includes any plants, inhabitants, decorations, and more). By making sure that you also read up on the correct environment that your fish require before placing them in your setup, you can fully remove this symptom and make sure that all of your fish will be acting like they would in their natural environment. Thus, when you do let them adjust to your water and you truly see how they are acting, eating and if they have any symptoms or signs, we will either start to get a better understanding if they are infected, or learn about what possible other diseases they might have.