I'm trying to convert
const std::string &s
to
std::string const & s
and can't seem to get it quite right. This is the regex I'm using:
%s/const \(.\{-}\) &/\1 const &
and the result I'm getting:
std::string const const std::string &s
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityJust escape the &
with a backslash.
%s/const \(.\{-}\) &/\1 const \&
The &
in the replace part inserts the entire matched pattern.
See :help s/\&
.