regex modify in vim

1
2
3
echo print 'hello' > test
echo print 'hello' >> test
echo print 'hello' >> test

use vim edit file vim test

1
2
3
4
5
6
7
8
9
10
11
shift + :
set number

shift + :
s/\vh(.*)o/y\1ow/g

shift + :
2,3s/\vh(.*)o/y\1ow/gc

shift + :
wq
1
2
3
4
more test
print 'yellow'
print 'yellow'
print 'yellow'

2,3 mean match scale in row 2 to 3.

in gc mode, y confirm one match, a confirm all match.

https://blog.csdn.net/hongchangfirst/article/details/10400915