Suppose that $X$ is a metric space. Is the family of all realvalued uniformly continuous functions on $X$ dense in the space of all continuous functions with respect to the topology of uniform convergence on compact sets?
Yes, and even more is true. The argument is as follows: let $f\colon X \to \mathbb R$ be a continuous function and let $K\subset X$ be a compact set. Then $f_K$ is uniformly continuous; let $\omega$ be its nondecreasing subadditive modulus of continuity. By McShaneWhitney's extension formula $f_K$ admits a uniformly continuous extension to $X$ with the same modulus  more concretely, $$F(x)=\inf\{f(k)+\omega(d(k,x))\colon k\in K\}$$ is this extension which is uniformly continuous on the whole $X$.

$\begingroup$ I'm glad we used the same argument with almost the same wording too bad I was 33'' delayed :) $\endgroup$ – Pietro Majer May 23 '18 at 10:13

$\begingroup$ Yes. Notice that some effort still has to be done to show that such a subadditive modulus can be really found. Effort which we both elegantly avoided ;) $\endgroup$ – Tony Prochazka May 23 '18 at 15:13

$\begingroup$ "let K⊂X be a compact." Is there a missing word "set" here? $\endgroup$ – Acccumulation May 23 '18 at 17:02

1$\begingroup$ @Tony: Yes: on the existence of special moduli of continuity, the wiki article treats this issue too (it's me who wrote it :) ) $\endgroup$ – Pietro Majer May 23 '18 at 17:38
Yes. For any compact subset $K\subset X$ consider a uniformly continuous extension of $f_{K}$ (there is such an extension even with the same subadditive modulus of continuity, see here). This shows that the uniformly continuous functions on $X$ are a dense subspace of $C(X)$ in the topology of uniform convergence on compacta.
Let $C(X)$ be the algebra of continuous functions endowed with the compactopen topology.
Notice that the functions $d_x : X \to [0, \infty)$ given by $d_x (y) = \min( d(x,y), 1)$ separate the points of $X$: if $d_x (p) = d_x (q)$ for all $x \in X$, taking $x = p$ gives $d_p(q) = 0$, whence $d(p,q) = 0$.
The functions $d_x$ are Lipschitz (with Lipschitz constant $1$). There are 3 cases to examine:
if $d(x,y) \le 1$ and $d(x,z) \le 1$, then $ d_x(y)  d_x(z)  = d(x,y)  d(x,z) \le d(y,z)$ by the triangle inequality;
if $d(x,y) \le 1$ and $d(x,z) > 1$ then
$$ d_x(y)  d_x(z)  = 1  d(x,y) \le d(x,z)  d(x,y) \le d(y,z)$$
again by the triangle inequality; similarly for $d(x,y) > 1$ and $d(x,z) \le 1$;
if $d(x,y) > 1$ and $d(x,z) > 1$ then $ d_x(y)  d_x(z)  =  1  1  = 0 \le d(y,z)$.
Remember now that the sum and product with scalars of Lipschitz functions are again Lipschitz, and that the product of bounded Lipschitz functions (and the $d_x$ are bounded) is again Lipschitz (of course, the Lipschitz constant changes).
Consider the subalgebra $A$ of $C(X)$ generated by the family $(d_x)_{x \in X}$ and the constant function $1$. By the preceding paragraph it will be made only of Lipschitz functions. Using the version of the StoneWeierstrass theorem for the compactopen topology (Stephen Willard, "General Topology", 1970, p. 293, par. 44B.3), the closure of $A$ is $C(X)$, so you get that not only uniformly continuous, but even Lipschitz functions are dense in $C(X)$