I am writing a macro a part of which is supposed to extract verse numbers from a string such as 11.1
, standing for "verse one in canto eleven". I search /11\.\zs
. The cursor now is in the right place. Now if I have a one-digit verse number, I'd just select it by v
, then yank it y
. Fine. But that works only for the first nine verses of each canto, normally it the number I need to yank will be two digits, sometimes three digits long. Also fine, ve
, BUT, then it doesn't work with one-digit verse numbers, as that will go to the end of the NEXT WORD, producing a very different effect from what I had in mind. How would I catch both the cases with the same key-stroke sequence?
Probably I'd just include the dot into the to-be-yanked word, and then later get rid of it, as that seems to work, or is there a more elegant way of doing the same thing?
yw
oryiw
(not in Visual mode) works. Alsoviw
(to select "inside word") followed byy
will work too. – filbranden♦ Jun 4 '20 at 17:11yw
will include the space after the word, butyiw
seems to be doing what is needed. – muk.li Jun 4 '20 at 17:18