Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there multiple range command for Vim or Vi?

I want to do something in range [a, b] and [c, d], or much more range.

For example, I want to replace "abc" with "def" in lines between 1~10, and lines between 50~60. I will do the two edit operation below:

(1) :1,10s/abc/def/g

(2) :50,60s/abc/def/g

Can I do this in just one command?

like image 853
mitcc Avatar asked Oct 21 '25 04:10

mitcc


1 Answers

You can't have a non-contiguous range but it's easy enough to repeat the same substitution on another range:

:1,10s/abc/def/g|50,60&&

See :help :&.

like image 71
romainl Avatar answered Oct 24 '25 21:10

romainl