To factor a quadratic of the form ax^2+bx+c you need to find two values, j and k, that satisfy two conditions:
ac=jk and b=j+k in this case:
ac=jk=-18 and b=j+k=7 so j and k must be 9 and -2
Now replace bx with jx and kx in the original equation...
x^2-2x+9x-18 and factor the 1st and 2nd pair of terms...
x(x-2)+9(x-2) which is equal to
(x+9)(x-2)