Suppose that $f: \mathbb{R} \rightarrow \mathbb{R}$ is a continuous function with $\lim_{x \rightarrow + \infty}f(x)=0$ and $\lim_{x \rightarrow - \infty}f(x)=0$. Show that $f$ is uniformly continuous on $\mathbb{R}$
My attempt: Take a random $\epsilon >0$. As $\lim_{x \rightarrow + \infty}f(x)=0$, there exists a $M_{1} \in \mathbb{R}$ so that for every $x \in \mathbb{R}$ with $x > M_{1}$ it holds that $|f(x)-0|< \epsilon$. As $\lim_{x \rightarrow - \infty}f(x)=0$, there exists a $M_{2} \in \mathbb{R}$ so that for every $x \in \mathbb{R}$ with $x < M_{2}$ it holds that $|f(x)-0|< \epsilon$. Now take $M \geq \max \{|M_{1}|,|M_{2}|\}$. Then surely will $|f(x)|< \epsilon$ for every $x \in \mathbb{R} \backslash [-M,M]$.
Now I'm not sure how to go on from this. I do know that $f$ is uniformly continuous on the interval $[-M,M]$ because it is continuous. But how can I expand this to $]- \infty,+\infty[$ ?
For every $|x| \ge M$.. $|f(x)| < \epsilon/3$. Then choose $\delta$ which works for $[-M,M]$ and take $x,y$ such that $|x-y| < \delta$. If $x$ and $y$ are both in $[-M,M]$ then nothing to prove and if both are outside $[-M,M]$ also nothing to prove. So without losing generality let us say $y<-M <x$. Then $|x-(-M)| < \delta$ and $|f(x) - f(-M)| < \epsilon/3$. But $|f(x)-f(y)| \le |f(x) - f(-M)| + |f(-M)| + |f(y)| < \epsilon/3 + \epsilon/3 + \epsilon/3 = \epsilon$.