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

47348Re: Change highlighted pattern, don't move cursor/window

Expand Messages
  • Gary Johnson
    Feb 1, 2004
      On 2004-02-01, Fred Ma <fma@...> wrote:
      > Hi,
      >
      > When I use vim to search for a pattern with the "/",
      > the cursor moves to the next occurance, and all matching
      > text is highlighted. That's almost exactly what I want.
      > I want to provide a pattern to highlight from the command
      > line, but I don't want the cursor to move, or the window
      > to scroll. I thought I could find where vim stores it's
      > notion of last pattern searched for, but can't seem to
      > find it. It isn't in hlsearch or search(). Is this
      > possible?

      How about this?

      :match Search /pattern/

      See

      :help match

      Vim keeps the search pattern in the "/ register, so you could also
      do this:

      :let @/ = "pattern"

      but that won't highlight the pattern unless search highlighting is
      already turned on. To turn in on, you can

      :set hls

      See also

      :help quote/
      :help @/

      HTH,
      Gary

      --
      Gary Johnson | Agilent Technologies
      garyjohn@... | Wireless Division
      | Spokane, Washington, USA
    • Show all 3 messages in this topic