I'd like to insert a word in multiple lines, is there any command like
which would insert
word at the beginning of line 2, line 3, line 5, line 7 and line 11?
Here, multiple lines are not contiguous.
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 community
Performing a substitution on several consecutive lines is pretty easy:
but a range can't cover non-consecutive lines.
With a bit of creativity, though, it is entirely possible to work around that "limitation".
Indeed, you can repeat the last substitution with
:&& (the former will not preserve the original flags, the latter will) so you can chain substitutions pretty easily:
:help :& and scroll around for