I'm aware that you can delete say lines 34-40 with
:34,40d
but is there a way to delete say lines 34-40 AND lines 43-45
something like
:34,40(?)43,45d
where (?) represents the symbol necessary to tell vim AND this second set of rows?
Thanks
The shortest way is just duplicating the :d[elete]
command and concatenating all commands in one command-line. For mutable commands (like :delete
), you need to start from the end, so that the line numbers are still valid:
:43,45d|34,40d
My PatternsOnText plugin provides (among many others) a :RangeDo
command that simplifies the handling, as it adapts the ranges for mutations and ensures that each line is processed only once:
:RangeDo 34,40 43,45 d
With or without plugin, each single range still results in a separate command invocation. To accumulate yanks in a single register, you have to use the uppercase version that appends (on all but the first invocation):
:34,40yank a | 43,45yank A
:let @a = '' | RangeDo 34,40 43,45 yank A
There's no usable built-in way to do exactly what you want.
But this is simple enough IMO:
There's another way to look at it. If those lines share a
pattern
, you could do: