Search and Replace with incremented values in Vim

前端 未结 5 527
北恋
北恋 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:35

    You could probably write a function for this, but I usually do something simpler. I use a key macro involving the ^A and ^X keys (increment and decrement a number). Use qa to start recording, do your stuff, using those keys with count modifiers (e.g 18^X), and just do say, 10@ afterwards.

提交回复
热议问题