We report on direct numerical simulations of two-dimensional, horizontally periodic Rayleigh–Bénard convection between free-slip boundaries. We focus on the ability of the convection to drive large-scale horizontal flow that is vertically sheared. For the Prandtl numbers (
$\mathit{Pr}$
) between 1 and 10 simulated here, this large-scale shear can be induced by raising the Rayleigh number (
$\mathit{Ra}$
) sufficiently, and we explore the resulting convection for
$\mathit{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
$\mathit{Ra}\rightarrow \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
$\mathit{Ra}$
. When the large-scale shear is present with
$\mathit{Pr}\lesssim 2$
, 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
$\mathit{Ra}$
for
$\mathit{Pr}=1$
. When the shear is present with
$\mathit{Pr}\gtrsim 3$
, the flow does not burst, and convective heat transport is sustained at all times. Nusselt numbers then grow roughly as powers of
$\mathit{Ra}$
, but the growth rates are slower than any previously reported for Rayleigh–Bénard convection without large-scale shear. We find that the Nusselt numbers grow proportionally to
$\mathit{Ra}^{0.077}$
when
$\mathit{Pr}=3$
and to
$\mathit{Ra}^{0.19}$
when
$\mathit{Pr}=10$
. Analogies with tokamak plasmas are described.