Search and Replace with incremented values in Vim

前端 未结 5 531
北恋
北恋 2021-01-31 03:57

Lets say I wrote a simple CSS rule like this:

.star_10 {
  background: url(stars.png) no-repeat 0 0;
}

And I need 10, so I copied it 9 times.

5条回答
  •  被撕碎了的回忆
    2021-01-31 04:37

    Just using pure vim resources, no scripting:

    :let c=10 | g/_\zs\d\+\ze/ s//\=c/ | let c-=1 
    :let c=0 | g/no-repeat 0 \zs\d\+/ s//\=c/ | let c-=18
    

提交回复
热议问题