This is likely a very trivial/silly question, but in following a derivation of the position and momentum commutation relation using the dirac notation, I am having trouble justifying a certain step.
Suppose we have some arbitrary Hilbert-space vector $|\psi\rangle$, and we want to know the commutator $[x,p]$ using dirac notation. Then, projecting this onto coordinate space
$$\langle x'|\hat{x}\hat{p} - \hat{p}\hat{x})|\psi\rangle = \langle x'|\hat{x}\hat{p}|\psi\rangle - \langle x'|\hat{p}\hat{x}|\psi\rangle = {\hbar \over i}\langle x'|\hat{x}|{d\over dx}\psi\rangle - \int\langle x'|\hat{p}|x\rangle \langle x|\hat{x}|\psi\rangle dx$$
Is the expansion in the x-basis for the $\langle x'|\hat{p}\hat{x}|\psi\rangle$ term because there is a derivative presumably acting on everything to the right, if not, what is the reason I can't just simply do $\langle x'|\hat{p}\hat{x}|\psi\rangle = x'\langle x'|\hat{p}|\psi\rangle$ and have $[x, p] = 0$. I would like to know if this is also a standard technique when deriving the other commutation relations (namely position and energy, and momentum and energy). Thank you.