A function vanishing at infinity is uniformly continuous If $f\in C_0(\mathbb{R})$ (i.e. $f$ continuous and for all $\varepsilon>0$ there is $R>0$ such that $|f(x)|<\varepsilon$ whenever $|x|>R$), then why is $f$ uniformly continuous? I know that we should somehow use that $f$ is "small" outside a compact interval (on which it is uniformly continuous), how can we nicely write down the $\delta$?
 A: Let  $U_δ(∞)=\{x ∈ R;\; |x| > 1/δ\} ∪ \{∞\}$. Then $f ∈ C_0(ℝ)$ if and only if $f ∈ C^0(ℝ)$ and for any $ε > 0$ there is an $δ > 0$ such that $f(U_δ(∞)) ⊂ U_ε(0)$.
For any $ε > 0$, pick an $δ > 0$ such that $f(U_δ(∞)) ⊂ U_{ε/2}(0)$, and then pick $δ' < δ$ to uniformly send $δ$-neighbourhoods in $[-\tfrac{2}{δ}..\tfrac{2}{δ}]$ to $ε/2$-neighbourhoods. Then, by the triangle inequality, $δ'$-neighbourhoods are sent to $ε$-neighbourhoods and you get uniform continuity of $f$ on $ℝ$.
Topologically speaking, functions in $C_0 (ℝ)$ are the same as function $S^1 → ℝ$. You can continuously extend them to functions on the one-point-compactification $ℝ ∪ \{∞\} \cong S^1$, which is compact and has a natural uniform structure using the $δ$-neighbourhoods defined above. From this viewpoint, the result follows from the known fact that continuous functions on compact uniform spaces are uniformly continuous.
A: We shall use the fact that a continuous function in a closed interval is uniformly continuous.
Let $f\in C_0(\mathbb R)$ and $\varepsilon>0$. We shall find a $\delta>0$, such that $\lvert x-y\rvert<\delta$ implies that $\lvert f(x)-f(y)\rvert<\varepsilon$.
As $\lim_{\lvert x\rvert\to\infty}f(x)=0$, there exists an $M>0$, such that $\lvert x\rvert>M$, implies that $\lvert f(x)\rvert<\varepsilon/3$.
Since $f$ is uniformly continuous in $[-M,M]$, there exists a $\delta>0$, such that
$x,y\in [-M,M]$ and $\lvert x-y\rvert<\delta$ implies that $\lvert f(x)-f(y)\rvert<\varepsilon/3$.
Now let $x,y\in\mathbb R$, with $\lvert x-y\rvert<\delta$.
Case I. $x,y\in [-M,M]$. Then indeed
$$\lvert f(x)-f(y)\rvert<\varepsilon/3<\varepsilon.$$
Case II. $|x|,|y|>M$. Then $\lvert f(x)\rvert<\varepsilon/3$ and
$\lvert f(y)\rvert<\varepsilon/3$ and hence $\lvert f(x)-f(y)\rvert<2\varepsilon/3<\varepsilon.$
Case III. $x\in [-M,M]$ and $\lvert y\rvert>M$. Assume that $y>M$. (The case where $y<-M$ is treated similarly.)
In this case
$$x\le M<y,$$ and hence $$|x-M|<|x-y|<\delta.$$
Also
$\lvert f(y)\rvert<\varepsilon/3$ and thus
$$
\lvert\, f(x)-f(y)\rvert\le \lvert\, f(x)-f(M)\rvert +\lvert\, f(M)-f(y)\rvert \\ \le \lvert\, f(x)-f(M)\rvert +\lvert\, f(M)|+|\,f(y)\rvert <\frac\varepsilon 3+
\frac\varepsilon 3+\frac\varepsilon 3=\varepsilon.
$$
A: Just for completeness, here's a proof that works for any locally compact metric space $X$.

Thm: If $X$ is a locally compact metric space, then $C_c(X)$ is dense in $C_0(X)$ under the sup-norm.

For a proof, see, e.g., Proposition 4.3.5 in Folland, who uses a different definition of $C_0(X)$ than OP which, it can be checked, is equivalent for $X=\mathbb{R}$.
Now, the proof is pretty straightforward. The key idea is that, if a function can be uniformly approximated by uniformly continuous functions, then it is, itself, uniformly continuous.
Indeed, suppose $f \in C_0(X)$. Give me $\varepsilon>0$. I find $g \in C_c(X)$ with $\|g-f\|_\infty < \varepsilon$. The $g$ that I found is uniformly continuous on all of $X$. So, let me then find $\delta>0$ with $d(x,y) < \delta \implies |g(x)-g(y)| < \varepsilon$. Finally, given $d(x,y) < \delta$, the trivial estimate yields $|f(x)-f(y)| < 3\varepsilon$.
