Re: Text color change, syntax or vim?
- "Antoine J. Mechelynck" wrote:
> ----- Original Message -----You might want to put this in an autocommand,
> From: "Wei Wang" <Wei.Wang@...>
> To: "Colin Keith" <vim@...>
> Cc: <vim@...>
> Sent: Friday, May 31, 2002 9:54 PM
> Subject: Re: Text color change, syntax or vim?
> > That's an option, too.
> > What I want is actually get rid of the search. Say I did a search in one
> > and the results are highlighted which is what I want. Then I close this
> file andopen another file with vim. The search is applied in this file as
> well, which
> > is not what I want. When I freshly open an vim, there is no search and no
> > corresponding highlight. How can I get back to this initial state after
> > several searches?
> either :nohls to just turn off highlighting until next search, or
> :let @/="" to also empty the last-search register.
:au BufEnter nohls
I leave it as an exercise to make BufLeave/BufEnter autocommands to save the
search register as a buffer variable, then either turn off search highlighting
(:noh) or restore the search history when changing buffers. (The hard part is
to avoid setting a buffer variable for bar.txt if you do
for example). OTOH, this is not always useful: often I want to keep the
search pattern as I switch from buffer to buffer.
HTH --Benji Fisher