Sunday, November 22, 2015

Re: Question about highlighting all matches of a local variable within a C/C++ subroutine

On Sunday, November 22, 2015 at 4:18:17 PM UTC-5, Richard Mitchell wrote:
> On Sunday, November 22, 2015 at 2:09:13 PM UTC-5, Richard Mitchell wrote:
> > On Sunday, November 22, 2015 at 11:13:41 AM UTC-5, DrChip wrote:
> > > Richard Mitchell wrote:
> >
> > > > I had trouble getting this to work.
> > > >
> > > > The first issue was SaveWinPosn was not defined. I found it in cecutil.vba, but I don't see this being mentioned as a prerequisite.
> > > >
> > > > Currently it doesn't seem to do anything, but hitting 'n' produces:
> > > >
> > > > E486: Pattern not found: \%(\%>0l\%<34l\)&MYSTRING
> > > >
> > > > (where MYSTRING is what was being searched for and does exist in the current C function).
> > > > It looks like 34 is the line after what may be considered the first block as enclosed by {}, but not the block the cursor is currently sitting.
> > > >
> > > > Is there more magic needed or is my environment conflicting?
> > > >
> > > Sorry about the SaveWinPosn problem -- funcsrch was on the wrong list so
> > > it didn't have cecutil.vim bundled with it. My website's version of
> > > funcsrch now has cecutil bundled with it.
> > >
> > > Do the normal mode commands [[ and ][ go to the beginning and ending of
> > > the function your cursor is in? Its possible that your style of coding
> > > prevents vim's method of recognizing beginning-ending of functions from
> > > working, and FuncSrch uses that.
> > >
> > > Regards,
> > > Charles Campbell
> >
> > I started using vi around 30+ years ago and considered myself reasonably competent (as a user), but I did not know about those two mode commands.
> >
> > ][ takes me to the end of the current function, or the next function if already at the end
> > [] takes me to the end of the previous function
> > ]] takes me to the end of the file
> > [[ takes me to the beginning of the file
> >
> > so no, they don't work exactly as you describe, at least [[ does't. I tried vim -u NONE file.c and still got the same behavior. If I have changed the default behavior, it is only because I've loaded someone's plugin with said side-effect. I use vim, I don't write stuff for vim. Obviously I'm prone to getting sucked into "that looks neat, lets try it!" or we wouldn't be having this discussion.
> >
> > Thanks,
> > Richard
>
> I see now, [[ works for:
>
> void func()
> {
> blah;
> }
>
> but not:
>
> void func() {
> blah;
> }
>
> so it is my coding style that breaks this use.

This map fixes it:

:map [[ ][%

All of my functions end with the } in the first column, so ][ takes the cursor to it. % then moves the cursor to the matching {

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: