On Fri, Nov 24, 2017 at 12:43:46PM EST, porphyry5 wrote: > On Thursday, November 23, 2017 at 3:53:58 PM UTC-8, Chris Jones wrote:
[..] > > Substitute (:h :s) will do all you need. In the case of links and > anchors, I modify this model to the specific situation in each case: > > :%s/ \(_\(\w\+\)\)/ <a href="#\1">\2<\/a>/g|:%s/^_\w\+$/<a > name="&"><\/a>/ Do you mean using submatch(0) to retrieve what /\d\+< actually matched in the current iteration? So far this seems to be the only way to retrieve the string that a regex actually matches... alas, as per the :help submatch vim manual... submatch() can only be used in the context of the replacement part of a :substitute command - which is not what I had in mind. Just curious. I gave up on the idea of using vim in this instance and wrote a ~10 lines python script that rewrites the file... adding the links where relevant. > Being simple minded, I just ensure that anchors always occur at the > start of lines, and that links never do. Always try to eat off of a clean plate when you can. The index file as tidied up by yours truly was nice and clean to start with... My little script only created ~10 faulty <a href= > links out of the 6,000+... which took c. 10 minutes to edit. All the same & just for the hell of it... doing it in vim would have been more satisfying. So if you could afford the time... could you explain the vim solution you had in mind? I'm still interested. Thanks, CJ -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
