I was trying to find out if it is possible to give an ex command a list of lines instead of a range?
1 Answer
From :h :range
it doesn't seem possible to use a list of numbers as a range.
I think that what you are looking for is the global command (:h :global
) which applies a command on the lines matching a pattern.
If you look at :h /ordinary-atom
you will see that \%Xl
allows you to match the line number X
. So for example if you have the following buffer:
foo
bar
fizz
fuzz
And you want to replace f
by F
on the first line you can do:
:g/\%1l/s/f/F
And if you want to do it on the first and third line:
:g/\%1l\|\%3l/s/f/F