Loading ...
Sorry, an error occurred while loading the content.

Re: Vim search highlight bug (I think)

Expand Messages
  • Benji Fisher
    ... It is at the end of the long paragraph under ... just above ... In other words, ... restores the search highlighting, but ... n1 (where n1 is mapped as
    Message 1 of 4 , Feb 3, 2006
    • 0 Attachment
      On Thu, Feb 02, 2006 at 11:19:34AM -0500, Halim, Salman wrote:
      >
      > > -----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...

      It is at the end of the long paragraph under

      :help :function

      just above

      :help :endfunction

      > But what about the first example, where I'm simply doing the equivalent
      > of hitting 'n'? That doesn't change the search pattern...

      In other words,

      :noh
      :execute 'normal! n'

      restores the search highlighting, but

      :noh
      n1

      (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
    Your message has been successfully submitted and would be delivered to recipients shortly.