We report on direct numerical simulations of two-dimensional, horizontally periodic Rayleigh-B\'enard convection, focusing on its ability to drive large-scale horizontal flow that is vertically sheared. For the Prandtl numbers ($Pr$) between 1 and 10 simulated here, this large-scale shear can be induced by raising the Rayleigh number ($Ra$) sufficiently, and we explore the resulting convection for $Ra$ up to $10^{10}$. When present in our simulations, the sheared mean flow accounts for a large fraction of the total kinetic energy, and this fraction tends towards unity as $Ra\to\infty$. The shear helps disperse convective structures, and it reduces vertical heat flux; in parameter regimes where one state with large-scale shear and one without are both stable, the Nusselt number of the state with shear is smaller and grows more slowly with $Ra$. When the large-scale shear is present with $Pr\lesssim2$, the convection undergoes strong global oscillations on long timescales, and heat transport occurs in bursts. Nusselt numbers, time-averaged over these bursts, vary non-monotonically with $Ra$ for $Pr=1$. When the shear is present with $Pr\gtrsim3$, the flow does not burst, and convective heat transport is sustained at all times. Nusselt numbers then grow roughly as powers of $Ra$, but the growth rates are slower than any previously reported for Rayleigh-B\'enard convection without large-scale shear. We find the Nusselt numbers grow proportionally to $Ra^{0.077}$ when $Pr=3$ and to $Ra^{0.19}$ when $Pr=10$. Analogies with tokamak plasmas are described., Comment: 25 pages, 12 figures, 5 videos