Monday, June 19, 2017

Re: decrease number?

On 2017-06-19 19:14, stosss wrote:
> <line x1="20" y1="45" x2="820" y2="45" stroke-width="1"
> stroke="#c0c0c0" />
>
> I want to change them like this:
>
> <line x1="10" y1="35" x2="810" y2="35" stroke-width="1"
> stroke="#c0c0c0" />
>
> The "ten" place holder needs to decrease by one.
> x1="20" y1="45" x2="820" y2="45"
>
> Can someone point me to something that would show me a fast way to
> do this?
>
> I am thinking some how I should be able to use CTRL-X in a search
> and replace but I don't know how to do it. I am guessing '\=' would
> be used. I really don't know how to put this together.

I'd go with your "\=" suggestion. Something like

:%s/\<[xy][12]="\zs[^"]*\ze"/\=submatch(0)-10/g

This only finds x1, x2, y1, and y2. You can relax the pattern a bit
if there are other variable-names in question.

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

No comments: