Re: Vim search highlight bug (I think)
- On Thu, Feb 02, 2006 at 11:19:34AM -0500, Halim, Salman wrote:
>It is at the end of the long paragraph under
> > -----Original Message-----
> > From: Bram@... [mailto:Bram@...]
> > Sent: Thursday, February 02, 2006 11:16 AM
> > > I've noticed an inconsistency (to me) in the highlights of search
> > > strings (Vim 7); take the following snippet:
> > >
> > > set hlsearch
> > > " DO THIS: Search for something simply like "ea" (without
> > > the quotes)
> > > nohls function! TestN()
> > > execute 'normal! n'
> > > endfunction
> > > nmap n1 :execute 'normal! n'<cr>
> > > nmap n2 :call TestN()<cr>
> > >
> > > Note how hitting n1 restores the highlight but hitting n2 does not,
> > > even though it does locate the search term.
> > >
> > > Am I missing something or have I uncovered something sinister here?
> > When you call a function the search pattern is saved and restored.
> > I can't find the place in the help files where this is mentioned...
> But what about the first example, where I'm simply doing the equivalentIn other words,
> of hitting 'n'? That doesn't change the search pattern...
:execute 'normal! n'
restores the search highlighting, but
(where "n1" is mapped as above) does not. This does seem like a bug to
me. (I just tested it under vim 6.4, but you say it behaves the same
under vim 7.) After all, :nmap is supposed to behave the same as if you
typed the keys yourself.
HTH --Benji Fisher