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

Re: Text color change, syntax or vim?

Expand Messages
  • Benji Fisher
    ... You might want to put this in an autocommand, ... I leave it as an exercise to make BufLeave/BufEnter autocommands to save the search register as a buffer
    Message 1 of 8 , Jun 2, 2002
    • 0 Attachment
      "Antoine J. Mechelynck" wrote:
      > ----- Original Message -----
      > 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
      > file
      > > 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
      > doing
      > > several searches?
      >
      > either :nohls to just turn off highlighting until next search, or
      > :let @/="" to also empty the last-search register.
      >
      > Tony.

      You might want to put this in an autocommand,

      :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

      :e foo.txt
      /foo
      :e bar.txt
      :e foo.txt

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