Hi Albert!

On Mo, 16 Aug 2010, Albert wrote:

> How can search for a number range like [1-20] (which works in
> something like BBEdit)?

I think this should work:
/\<\%([0-9]\|[^2-9][0-9]\|20\)\>

Which translates roughly to
\<          " beginning of a word
\%(...\)    " Start a group
[0-9]       " either 0-9
\|          " or
[^2-9][0-9] " 00 until 19
\|          " or
20          " 20
\>          " end of word

If you would like to replace only the number range 1-20, you can also 
use an expression when evaluating the replacement part (which is not 
exactly the same, but should work anyway ;)

:%s/\d\+/\=submatch(0)>20?submatch(0):submatch(0).'foobar'/g

which would add the string 'foobar' to every number that isn't greater 
than 20.

HTH and regards,
Christian

-- 
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

Reply via email to