Vibrational spectroscopies using infrared radiation, Raman scattering, neutrons, low-energy electrons and inelastic electron tunnelling are powerful techniques that can analyse bonding arrangements, identify chemical compounds and probe many other important properties of materials. The spatial resolution of these spectroscopies is typically one micrometre or more, although it can reach a few tens of nanometres or even a few ångströms when enhanced by the presence of a sharp metallic tip. If vibrational spectroscopy could be combined with the spatial resolution and flexibility of the transmission electron microscope, it would open up the study of vibrational modes in many different types of nanostructures. Unfortunately, the energy resolution of electron energy loss spectroscopy performed in the electron microscope has until now been too poor to allow such a combination. Recent developments that have improved the attainable energy resolution of electron energy loss spectroscopy in a scanning transmission electron microscope to around ten millielectronvolts now allow vibrational spectroscopy to be carried out in the electron microscope. Here we describe the innovations responsible for the progress, and present examples of applications in inorganic and organic materials, including the detection of hydrogen. We also demonstrate that the vibrational signal has both high- and low-spatial-resolution components, that the first component can be used to map vibrational features at nanometre-level resolution, and that the second component can be used for analysis carried out with the beam positioned just outside the sample--that is, for `aloof' spectroscopy that largely avoids radiation damage.