From this question we know that if $x\in\mathbb{R}^{n\times1}$ is a vector, then the (normalized) outer product matrix $$ \frac{x x^\top}{||x||^2}\, \in \mathbb{R}^{n\times n} $$ can operate on another vector $y\in\mathbb{R}^{n\times 1}$ and projects orthogonally onto the line spanned by $x$.
How does this generalize to a basis of vectors?
Suppose $X\in\mathbb{R}^{n\times m}$ is a matrix and let $[x_1 \, \cdots x_m]$ be its columns. I would like to find a matrix $A\in\mathbb{R}^{n\times n}$ such that it projects a vector $y\in\mathbb{R}^{n\times 1}$ onto the space spanned by the columns on $X$.
I have chosen to rewrite my answer since my recollection of the formula was not quite satisfactionary. The formula I presented actually holds in general. If $A$ is a matrix, the matrix
$$P = A (A^\top A)^{-1} A^\top$$
is always the projection onto the column space of $A$. In the case where $A$ is orthogonal, this reduces to $AA^\top$. You can find a simple derivation under "Intuition" in this Wikipedia-article: https://en.wikipedia.org/wiki/Projection_matrix.