Well I can't think of a book reference, although I'm sure some people on this board can.
The hilbert space for a 1-d quantum particle is infinite dimensional. In the energy basis, it is a discretely infinite thing, whereas in the position basis it is continuously infinite.
You just need to get into a habit of thinking about functions as infinite dimensional vectors, and operators as matrices.
It might help you visualise it if you do a discretised case writing out differentiation as a finite difference matrix (eg using Matlab). The hamiltonian above is non-diagonal because differential operators aren't diagonal in the position basis. (even though paradoxically they come attached with a delta function).
Its important to remember that *all* operators should come with two indices. Just as a matrix has two subscripts, an operator on a function can always be thought of as a matrix multiplication by representing it with a kernel:
[tex]
(\mathsf A \mathbf{f})(x) = \int dx' A(x,x')f(x')[/tex]
c.f
[tex]
(\mathsf A v)_i = \sum_j A_{ij}v_j[/tex]
Once you realize that the differential operator is really
[tex]
D(x,x')=\delta(x-x')\frac{d}{dx'}[/tex]
and that the position operator is really
[tex]
X(x,x')=\delta(x-x')x'[/tex]
then the analogy with finite-d linear algebra becomes very clear, and constructing matrix elements doesn't feel as unnatural.