  Motivated by applications to the theory of rank-metric codes, we study the
problem of estimating the number of common complements of a family of subspaces
over a finite field in terms of the cardinality of the family and its
intersection structure. We derive upper and lower bounds for this number, along
with their asymptotic versions as the field size tends to infinity. We then use
these bounds to describe the general behaviour of common complements with
respect to sparseness and density, showing that the decisive property is
whether or not the number of spaces to be complemented is negligible with
respect to the field size. By specializing our results to matrix spaces, we
obtain upper and lower bounds for the number of MRD codes in the rank metric.
In particular, we answer an open question in coding theory, proving that MRD
codes are sparse for all parameter sets as the field size grows, with only very
few exceptions. We also investigate the density of MRD codes as their number of
columns tends to infinity, obtaining a new asymptotic bound. Using properties
of the Euler function from number theory, we then show that our bound improves
on known results for most parameter sets. We conclude the paper by establishing
general structural properties of the density function of rank-metric codes.
