I’d like to automatically take a visually selected block of text, such as
51-100, and have it expanded into 51,52,53,...,99,100.
Is there an easy way to do this in vimscript?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Let me propose the following implementation.
If it is guaranteed by the range notation that there is no whitespace around
numbers, the second statement of
ExpandRange()can be simplified by usingthe
split()function,Note that the text denoting a range is put into the unnamed register. If it
is preferable to leave the register untouched, modify
ExpandRange()to saveits state beforehand and restore it afterwards.