Reputation: 821
I'm missing something subtle and silly on this. I have a short vim script. In it, I'm trying to do:
s/.*_____.*/\=repeat('=', 78)/
(That's the exact code.)
When I do /\v.*____.*
in normal mode, I can successfully find the pattern (more than once). When I do that substition in normal mode, it succeeds.
I'm sure I'm missing something as far as escaping a character somewhere. Please enlighten me!
Upvotes: 2
Views: 123
Reputation: 172570
A s/
command only covers the current line; this is not what you usually want.
The simplest approach is to use %s/...
to process the entire buffer. However, your mapping / command may want to support arbitrary ranges. For that, :call
will usually invoke your user-defined function once for each line, unless you define the function that it handles the range itself. See :help function-range-example
for details.
Upvotes: 1