Loading ...
Sorry, an error occurred while loading the content.

[Q] How can I find numbers from given interval

Expand Messages
  • Stanislav Krasnoyarov
    For example I have following block of numbers 10 15 18 30 0 23 And I want to find (highlight) numbers that less than 20 and more than 10. How can I do that? --
    Message 1 of 4 , Nov 29, 2002
    • 0 Attachment
      For example I have following block of numbers

      10 15 18 30 0 23

      And I want to find (highlight) numbers that less than 20 and more than 10.
      How can I do that?

      --
      Stanislav Krasnoyarov
    • Derek Wyatt
      This should do it: / ... -- ... Derek Quinn Wyatt | Phone: (905) 886-7818 ext. 2313 Syndesis Engineering | Fax: (905) 886-9076
      Message 2 of 4 , Nov 29, 2002
      • 0 Attachment
        This should do it:

        /\<1[1-9]\><CR>


        On Fri, Nov 29, 2002 at 05:17:40PM +0300, Stanislav Krasnoyarov wrote:
        | For example I have following block of numbers
        |
        | 10 15 18 30 0 23
        |
        | And I want to find (highlight) numbers that less than 20 and more than 10.
        | How can I do that?
        |
        | --
        | Stanislav Krasnoyarov

        --
        -----------------------------------------------------------
        Derek Quinn Wyatt | Phone: (905) 886-7818 ext. 2313
        Syndesis Engineering | Fax: (905) 886-9076
        Toronto, Ontario, CAN | Email: wyatt@...
        -----------------------------------------------------------
        "Information about package holidays on the FrogStar are
        available in the leaflet, 'Sun, Sand and Suffering on the
        most totally evil place in the galaxy'"
      • Derek Wyatt
        ... That s a bit different :) And it s something i don t have the answer to (i ve cc ed the vim list in case someone else knows). Regs, Derek ... -- ... Derek
        Message 3 of 4 , Nov 29, 2002
        • 0 Attachment
          | Well, I have to admit, it was a bad examle. I need more generic solution.
          | What about searching numbers from 1 564 033 to 1 598 730?

          That's a bit different :)

          And it's something i don't have the answer to (i've cc'ed the vim list in
          case someone else knows).

          Regs,
          Derek

          |
          | -----Original Message-----
          | From: Derek Wyatt [mailto:wyatt@...]
          | Sent: Friday, November 29, 2002 5:36 PM
          | To: Stanislav Krasnoyarov
          | Cc: 'vim@...'
          | Subject: Re: [Q] How can I find numbers from given interval
          |
          |
          | This should do it:
          |
          | /\<1[1-9]\><CR>
          |
          |
          | On Fri, Nov 29, 2002 at 05:17:40PM +0300, Stanislav Krasnoyarov wrote:
          | | For example I have following block of numbers
          | |
          | | 10 15 18 30 0 23
          | |
          | | And I want to find (highlight) numbers that less than 20 and more than 10.
          | | How can I do that?
          | |
          | | --
          | | Stanislav Krasnoyarov
          |
          | --
          | -----------------------------------------------------------
          | Derek Quinn Wyatt | Phone: (905) 886-7818 ext. 2313
          | Syndesis Engineering | Fax: (905) 886-9076
          | Toronto, Ontario, CAN | Email: wyatt@...
          | -----------------------------------------------------------
          | "Information about package holidays on the FrogStar are
          | available in the leaflet, 'Sun, Sand and Suffering on the
          | most totally evil place in the galaxy'"

          --
          -----------------------------------------------------------
          Derek Quinn Wyatt | Phone: (905) 886-7818 ext. 2313
          Syndesis Engineering | Fax: (905) 886-9076
          Toronto, Ontario, CAN | Email: wyatt@...
          -----------------------------------------------------------
          "Information about package holidays on the FrogStar are
          available in the leaflet, 'Sun, Sand and Suffering on the
          most totally evil place in the galaxy'"
        • BStrohhaecker@Hueller-Hille.com
          Von: Derek Wyatt [mailto:wyatt@syndesis.com] Gesendet: Freitag, 29. November 2002 15:44 ... solution. ... [...] I ve no idea how to do this with pure VIM. But
          Message 4 of 4 , Dec 2, 2002
          • 0 Attachment
            Von: Derek Wyatt [mailto:wyatt@...]
            Gesendet: Freitag, 29. November 2002 15:44

            > > Well, I have to admit, it was a bad examle. I need more generic
            solution.
            > > What about searching numbers from 1 564 033 to 1 598 730?
            >
            > That's a bit different :)
            >
            > And it's something i don't have the answer to (i've cc'ed the vim list in
            > case someone else knows).
            [...]

            I've no idea how to do this with pure VIM. But with a small
            (g)awk-script you can mark all numbers in your range with e.g.
            underscores and then search for '_\d\+_'.

            Try ':%!gawk -v FIRST_NUM=xxx -v LAST_NUM=yyy -f range.awk' with
            range.awk:

            { for ( i = 1; i <= NF; i++) {
            if ($i >= FIRST_NUM && $i <= LAST_NUM ) {
            $i = "_" $i "_";
            }
            }
            print $0;
            }

            Only a workaround, but works fine for me.

            Bernd
          Your message has been successfully submitted and would be delivered to recipients shortly.