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

Re: Finding empty methods

Expand Messages
  • Preben Guldberg
    ... Or differently (expand it as you like) fun EmptyMethodLines() let str = g/{ _s +}/let str = str . . line( . ) if str != echo bufnr( % ) . : .
    Message 1 of 7 , Nov 1, 2001
    • 0 Attachment
      Thus wrote Scott LaBounty (slabounty@...) on [011101]:
      > I'm trying to find empty methods in vim using:

      > /{\_s\+}

      > to search. What I would like is functionality similar to the :grep but this
      > uses grep itself which doesn't understand the \_s notation for searching
      > across multiple lines. I tried using bufdo and it does go through all of the
      > files but I can't get a list of where it found the empty methods at. Any
      > ideas?

      Just a rough idea:

      :bufdo echo '=== '.bufnr('%').': '.expand('%').' ===' | g/{\s_\+}/#

      Or differently (expand it as you like)

      fun EmptyMethodLines()
      let str = ''
      g/{\_s\+}/let str = str . ' ' . line('.')
      if str != ''
      echo bufnr('%') . ': ' . expand('%') . '"' . "\t" . str
      endif
      endfun

      and then do

      :bufdo call EmptyMethodLines()

      Peppe
      --
      "Before you criticize someone, walk
      Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
      c928400@... (o o) he gets angry, he'll be a mile away
      ----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
    • lwwickla@rockwellcollins.com
      Say, I guess I just missed it in the regexp section of the help (:h regexp / _s) but what does _s mean? And for that matter, is there any pattern of meaning
      Message 2 of 7 , Nov 1, 2001
      • 0 Attachment
        Say, I guess I just missed it in the regexp section of the help (:h regexp
        /\\_s) but what does \_s mean? And for that matter, is there any pattern
        of meaning ot these new metacharacters that have an underscore in them?

        Thanks

        Leif




        "Preben Guldberg" <c928400@...> on 11/01/2001 01:54:16 PM

        Please respond to Preben Peppe Guldberg <c928400@...>

        To: "Vim \(E-mail\)" <vim@...>
        cc:

        Subject: Re: Finding empty methods


        Thus wrote Scott LaBounty (slabounty@...) on [011101]:
        > I'm trying to find empty methods in vim using:

        > /{\_s\+}

        > to search. What I would like is functionality similar to the :grep but
        this
        > uses grep itself which doesn't understand the \_s notation for searching
        > across multiple lines. I tried using bufdo and it does go through all of
        the
        > files but I can't get a list of where it found the empty methods at. Any
        > ideas?

        Just a rough idea:

        :bufdo echo '=== '.bufnr('%').': '.expand('%').' ===' | g/{\s_\+}/#

        Or differently (expand it as you like)

        fun EmptyMethodLines()
        let str = ''
        g/{\_s\+}/let str = str . ' ' . line('.')
        if str != ''
        echo bufnr('%') . ': ' . expand('%') . '"' . "\t" . str
        endif
        endfun

        and then do

        :bufdo call EmptyMethodLines()

        Peppe
        --
        "Before you criticize someone, walk
        Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
        c928400@... (o o) he gets angry, he'll be a mile away
        ----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
      • Preben Guldberg
        ... Have a look at ... Peppe -- Before you criticize someone, walk Preben Peppe Guldberg __/- __ a mile in his shoes. That way, if
        Message 3 of 7 , Nov 1, 2001
        • 0 Attachment
          Thus wrote lwwickla@... (lwwickla@...) on [011101]:

          > Say, I guess I just missed it in the regexp section of the help (:h regexp
          > /\\_s) but what does \_s mean? And for that matter, is there any pattern
          > of meaning ot these new metacharacters that have an underscore in them?

          Have a look at

          :help /\_

          Peppe
          --
          "Before you criticize someone, walk
          Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
          c928400@... (o o) he gets angry, he'll be a mile away
          ----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
        • Kalle Bjorklid
          ... the ).* _s* is needed because only the first line is echoed, and the { might not be on the same line with the declaration. And the .* is there to
          Message 4 of 7 , Nov 1, 2001
          • 0 Attachment
            On Thu, 1 Nov 2001, Scott LaBounty wrote:

            > I'm trying to find empty methods in vim using:
            >
            > /{\_s\+}
            >
            > to search. What I would like is functionality similar to the :grep but this
            > uses grep itself which doesn't understand the \_s notation for searching
            > across multiple lines. I tried using bufdo and it does go through all of the
            > files but I can't get a list of where it found the empty methods at. Any
            > ideas?

            I came up with this:
            :bufdo :g/).*\_s*{\_s*}/echo bufname(".") . ' ' . line(".") . ': ' . getline(".")

            the ').*\_s*' is needed because only the first line is echoed, and the '{'
            might not be on the same line with the declaration. And the '.*' is there
            to allow the 'throws...' stuff in Java (which can be on several lines, of
            course, but I'm too tired to think how to do it right :-).

            --
            "Kalle" Karl-Mikael Bjorklid
            E-Mail: bjorklid@...
            Work-related: kalle.bjorklid@...
            WWW: www.cc.jyu.fi/~bjorklid/
          • Scott LaBounty
            Thanks to you both Kelle and Preben it works great! Preben, I think you meant: bufdo echo === .bufnr( % ). : .expand( % ). === | g/{ _s +}/# and not:
            Message 5 of 7 , Nov 1, 2001
            • 0 Attachment
              Thanks to you both Kelle and Preben it works great!

              Preben, I think you meant:
              bufdo echo '=== '.bufnr('%').': '.expand('%').' ===' | g/{\_s\+}/#

              and not:

              bufdo echo '=== '.bufnr('%').': '.expand('%').' ===' | g/{\s_\+}/#

              i.e. \_s and not \s_

              Scott LaBounty
              Netaphor Software, Inc.

              -----Original Message-----
              From: Kalle Bjorklid [mailto:bjorklid@...]
              Sent: Thursday, November 01, 2001 1:24 PM
              To: Scott LaBounty
              Cc: Vim (E-mail)
              Subject: Re: Finding empty methods


              On Thu, 1 Nov 2001, Scott LaBounty wrote:

              > I'm trying to find empty methods in vim using:
              >
              > /{\_s\+}
              >
              > to search. What I would like is functionality similar to the :grep but
              this
              > uses grep itself which doesn't understand the \_s notation for searching
              > across multiple lines. I tried using bufdo and it does go through all of
              the
              > files but I can't get a list of where it found the empty methods at. Any
              > ideas?

              I came up with this:
              :bufdo :g/).*\_s*{\_s*}/echo bufname(".") . ' ' . line(".") . ': ' .
              getline(".")

              the ').*\_s*' is needed because only the first line is echoed, and the '{'
              might not be on the same line with the declaration. And the '.*' is there
              to allow the 'throws...' stuff in Java (which can be on several lines, of
              course, but I'm too tired to think how to do it right :-).

              --
              "Kalle" Karl-Mikael Bjorklid
              E-Mail: bjorklid@...
              Work-related: kalle.bjorklid@...
              WWW: www.cc.jyu.fi/~bjorklid/
            • Piet Delport
              ... They re essentially a way of doing multi-line matches. For example: /foo _.*bar will match everything between (and including) foo and bar, across multiple
              Message 6 of 7 , Nov 3, 2001
              • 0 Attachment
                On Thu, 01 Nov 2001 at 14:39:36 -0600, lwwickla@... wrote:
                >
                > Say, I guess I just missed it in the regexp section of the help (:h regexp
                > /\\_s) but what does \_s mean? And for that matter, is there any pattern
                > of meaning ot these new metacharacters that have an underscore in them?

                :h /\_
                :h /\_$
                :h /\_.
                :h /\_^
                :h /\_[]

                They're essentially a way of doing multi-line matches. For example:

                /foo\_.*bar

                will match everything between (and including) foo and bar, across
                multiple lines if necessary.

                --
                Piet Delport <siberiyan@...>
                Today's subliminal thought is:
              Your message has been successfully submitted and would be delivered to recipients shortly.