I'm going through Sergio Dutra's Cavity Electrodynamics: The Strange Theory of Light in a Box. In equation (2.31) he computes:
$$\begin{aligned}\langle x|\hat{p}|x'\rangle&=i\hbar\int\frac{dk}{2\pi}\frac{e^{i(x-x')k}}{x-x'}\\\\ &=-\frac{i\hbar}{2\pi}\int dk\,e^{i(x-x')k}ik \\\\ &=\frac{\hbar}{i}\frac{\partial}{\partial x}\delta(x-x').\end{aligned}\tag{2.31}$$
The author claims that the second line arises via integration by parts, but I can't quite see how.
With integration by parts we have $$\int_a^b u dv = uv\rvert_a^b-\int_a^b vdu.$$ I assume we take $$u=\frac{e^{i(x-x')k}}{x-x'},\;dv=1.$$ This gives $$i\hbar\int\frac{dk}{2\pi}\frac{e^{i(x-x')k}}{x-x'}=\left.\frac{i\hbar}{2\pi}\frac{e^{i(x-x')k}}{x-x'}k\right\rvert_{k=-\infty}^{k=+\infty}-\frac{i\hbar}{2\pi}\int dk\,e^{i(x-x')k}ik.$$
If the boundary term vanishes, then I recover Dutra's derivation. However, I can't see why the term term should vanish. We have an increasing function $k$, multiplied by a complex oscillation, so the limit is not defined. Why should we take this to be zero, rather than some other constant? I understand that something weird must be happening, since the result is a distribution rather than a function.
EDIT: So having looked at some other answers on this site, my understanding that Dutra's derivation here isn't valid. As QMechanic says dividing a distribution by $x$ isn't defined. This stackexchange answer shows that the expression $\delta(x)/x$ can be manipulated to give multiple different answers.