Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Vimnastics: Writing Repetitive Markup in Vim
<select>
<option value="100">$100</option>
<option value="200">$200</option>
<option value="300">$300</option>
<!-- and so on... -->
</select>
<select>
<option value="100">$100</option>
</select>
# vim normal mode commands
qa # start recording our macro in the “a” register
yy # yank the current line
p # paste the yanked line
/\d<return> # search for the next digit (1 in this case)
100<ctrl-A> # increment 100 times
n # repeat the last search (\d)
100<ctrl-A> # increment 100 times*
q # stop recording our macro
<select>
<option value="100">$100</option>
<option value="200">$200</option>
<option value="300">$300</option>
</select>
<select>
<option value="100">$100</option>
<option value="200">$200</option>
<option value="300">$300</option>
<option value="400">$400</option>
<option value="500">$500</option>
<option value="600">$600</option>
<option value="700">$700</option>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.