Hi,
On 11/13/06, Ben K. <[EMAIL PROTECTED]> wrote:
Vimmers,
I have a long source code consisting of multiple modules wrapped in {}.
Sometimes I use "*" to find the next match. But I'd like to search only
within the same module or class that I started from. (which is wrapped
inside sub ... {})
In the following example, I'd like * or "n" to at least let me know that I
crossed the module boundary for instance 3. Or not match it at all.
If there's a way to highlight between the matching brackets
(open/close),
it would also be helpful, even if it doesn't allow highlighting of the
searched pattern.
You can use the command Vib to highlight all the lines between the
opening and closing braces.
V - start linewise visual mode
ib - Inner block text object
To search for a pattern within only a selected range of lines, you
can use the following command:
command! -nargs=* -range RS exe 'normal /\%>' . (<line1> - 1) . 'l\%<'
. (<line2> + 1) . 'l<args><CR>'
The above command should be all in one line and you can add this
to your .vimrc file.
With the above command, after visually selecting a block, you can use
:RS mypattern
- Yegappan
sub aaa {
...
instance 1 # Begin by "*"
...
instance 2 # This is OK.
...
}
sub bbb {
...
instance 3 # This is not what I want
...
}
Is there a simple way to do it?
Thanks.
Ben K.
Developer
http://benix.tamu.edu