Sunday, June 21, 2020

Re: An interesting little poser [PS]

On 2020-06-21 18:57, Tim Chase wrote:
> To build this associative array, you might try
>
> :$?^$?,$g/\[\d\+\]/let b:a[getline('.')]=getline(line(".")+1)

Whoops, before you do this, you might have to let vim know that b:a
is an array:

:let b:a={}
:$?^$?,$g/\[\d\+\]/let b:a[getline('.')]=getline(line(".")+1)

> You can then use
>
> :1,$?^$?s/\[\d\+]/\='^['.b:a[submatch(0)].']'/g

Oh, this also assumes that all footnote-references have corresponding
entries in the footnote block. If you have a [13] and there's no
[13] footnote at the bottom, that substitute will yell at you about a
"E716: Key not present in Dictionary: {bogus footnote}"

-tim

--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200621190214.7ca5c9ea%40bigbox.attlocal.net.

No comments:

Post a Comment