Tuesday, March 12, 2013

Re: Can I use split() on this?

On Wednesday, March 13, 2013 10:23:41 AM UTC+13, andalou wrote:
> How to convert from
>
> [uno\dos\tres](fijo)
>
> to
>
> [uno](fijo)
> [dos](fijo)
> [tres](fijo)

I take it that uno, dos, tres are arbitrary, and that you might have, say,

[uno\dos\tres\cuatro\cinco](fijo)

I use a repeated substitute for changes like this. First, I experimented with a search that matches the last item followed by the "fixed" stuff (see, I can use Google, woo hoo):

/\\[^\\]\+]([^)]\+)

until I've got it right. Then I put capturing parentheses (in vim that's "\(" and "\)") around the interesting bits and to make sure it still matched:

/\\\([^\\]\+\)](\([^)]\+\))

Then, a substitute:

:s//](\2)\r[\1](\2)

When that worked, move back to the right line and:

:while 1 | & | - | endwhile

Regards, John Little

--
--
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.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: