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.
Vim can search for text that spans multiple lines. For example, the search /hello\_sworld finds "hello world" in a single line, and also finds "hello" ending one line, with "world" starting the next line.
To make the quantifier non-greedy you simply follow it with a '?' the first 3 characters and then the following 'ab' is matched. greedy by appending a '?' symbol to them: *?, +?, ??, {n,m}?, and {n,}?.
vim uses \_.
to include the newline character to the common .
.
/\vdef\_.{-}end
In my version of Vim, you need to escape the {
, as well as using \_.
as other answers have said:
/def\_.\{-}end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With