For example, say I want to replace foo with bar on lines 1,3,11, and 15. How could I do that?
:1,15s/foo/bar
will replace foo with bar on lines 1-15. But I want to specify multiple individual lines (1,3,11,15), not a range (1-15).
How do you come up with the line numbers? If this is a manual process of visual inspection, you could make use of the multiselect plugin. It allows you to select multiple, non-contiguous ranges, and then you can apply a command on them:
:MSExecCmd s/foo/bar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With