0

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 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.