Thursday, September 1, 2011

Re: Search and write

On 09/01/11 01:10, Lars Iselid wrote:
> I want to write the digits and actually my full regex in vim
> is: /[-0-9]\{13,17\}
>
> I want numbers with 13 to 17 digits even if they have hyphens
> between the digits.

For this, I'd tend to do something like put each match on its own
line and then delete all lines that don't contain that pattern.
Something like

:%s/[-0-9]\{13,17\}/\r&\r/g
:v/[-0-9]\{13,17\}/d

Note that this does modify your current buffer, so either (1)
operate on a scratch buffer or (2) remember to undo it before
saving if your original source data isn't easily reproducible.

It gets a little trickier if you have multiple matches on the
same line AND you want to keep them on the same line (the above
puts each match in the same line onto its own line).

-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

No comments: