15

I am trying to search ruby file and find all methods (before autoreplacing them later). In vim, i use following regexp:

/\vdef.*(\n.*){-}end

However even though i use "{-}", it selects whole file's contents.

Pavel K.
  • 6,697
  • 8
  • 49
  • 80
  • 1
    I don't understand what you want to match. How about if there is an `if ... end` condition inside a function? – Birei Nov 01 '13 at 18:46
  • 1
    yes i'll modify regexp later accordingly (like add positive lookahead for another def or smth like that). what i need right now is way to search it non-greedily – Pavel K. Nov 01 '13 at 18:51

3 Answers3

13

uses \_. to include the newline character to the common ..

/\vdef\_.{-}end
Birei
  • 35,723
  • 2
  • 77
  • 82
8

In my version of Vim, you need to escape the {, as well as using \_. as other answers have said:

/def\_.\{-}end
user2161673
  • 81
  • 1
  • 1
5

Try following regex.

/\vdef(\n|.){-}end

.* was culprit in your case

jkshah
  • 11,387
  • 6
  • 35
  • 45