I copied lines from an enumerated list in this blog and pasted it to Vim. The content in each list item was seen in the current Vim buffer, but not the numbers.
An illustration of the problem
A sample ordered list with 2015 items
- Item one
- Item two
- Item three
- Item 2015
What is seen in Vim after copy and paste
Item one Item two Item three ... Item 2015
If one writes in Markdown and he/she copies a numbered list from elsewhere to a text editor, then it will be very inconvenient to manually add back the numbers. To exaggerate this inconvenience, I put “2015” above.
Insert the item number at the beginning.
1. Item one 2. Item two 3. Item three ... 2015. Item 2015
I read chapters 28–30 and 36 of
Learn Vimscript the Hard Way by Steve Losh, and searched
“vim loop through lines” on Google. After I saw
while liner <
line("$") in a forum thread, I typed the following editor commands in
1 2 3 4 5 6
exe "norm! used instead of
\<esc> can’t go
norm. Similarly, to include compound keys like
norm!, insert a backslash